运行 使用 IntelliJ 进行 JUnit 测试
Run JUnit test with IntelliJ
我正在使用 IntelliJ 2018.1,我正在尝试 运行 TeaVM JUnit 测试,但是当 运行 从 CTRL + SHIFT + F10 进行测试时 测试被跳过:
@RunWith(TeaVMTestRunner.class)
@SkipJVM
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ShapeTest {
static final Logger logger = Logger.getLogger(ShapeTest.class.getName());
@Rule
public final ExpectedException exception = ExpectedException.none();
@Test
public void testGet() {
System.out.println("ShapeTest - testGet");
String response = Shape.get("https://httpbin.org/get")
.header("accept", "application/json")
.header("Content-Type", "application/json")
.asJson();
JSONObject json = new JSONObject(response);
String url = json.getString("url");
JSONObject headers = json.getJSONObject("headers");
assertNotNull(json);
assertNotNull(url);
assertNotNull(headers);
System.out.println(json.toString());
}
}
但是当 运行从终端使用下面的命令时,它起作用了:
mvn test -Dteavm.junit.target=target/js-tests -Dteavm.junit.js.runner=h
tmlunit -Dteavm.junit.js.threads=2
这里的 IntelliJ/JUnit 专家可能知道为什么会发生这种情况?
如果你像我一样是 intellij 的新手。我写了 junits,只想 运行 它们。在eclipse中,你去testclass->右键->运行->as junit。我们有点像这样。它在intellij中也很相似。转到测试 class 右键单击和 运行 作为 junits。
如果这样的选项不可用,那么问题可能出在
file->project structure->module->source 此处您的测试不能配置到您的 repo 的测试文件夹中。
因此,在 project structure->module->sources 中点击 test in module 然后 select the path to test folder 。然后申请->确定。
现在 运行 作为测试选项将在右键单击测试 class 时可用。
您可以在 运行 配置设置中指定相同的 -D
参数。按 "Run"(在 Windows 上按 Alt+Shift+F10,在 Mac 上按 Ctrl+Alt+R),select 您的 运行 配置,向右箭头,编辑:
然后在VM选项下指定所有-D
参数:
之后,选项将传递给 TeaVM 运行ner,就像它与 mvn test
命令一起工作一样。
我正在使用 IntelliJ 2018.1,我正在尝试 运行 TeaVM JUnit 测试,但是当 运行 从 CTRL + SHIFT + F10 进行测试时 测试被跳过:
@RunWith(TeaVMTestRunner.class)
@SkipJVM
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ShapeTest {
static final Logger logger = Logger.getLogger(ShapeTest.class.getName());
@Rule
public final ExpectedException exception = ExpectedException.none();
@Test
public void testGet() {
System.out.println("ShapeTest - testGet");
String response = Shape.get("https://httpbin.org/get")
.header("accept", "application/json")
.header("Content-Type", "application/json")
.asJson();
JSONObject json = new JSONObject(response);
String url = json.getString("url");
JSONObject headers = json.getJSONObject("headers");
assertNotNull(json);
assertNotNull(url);
assertNotNull(headers);
System.out.println(json.toString());
}
}
但是当 运行从终端使用下面的命令时,它起作用了:
mvn test -Dteavm.junit.target=target/js-tests -Dteavm.junit.js.runner=h
tmlunit -Dteavm.junit.js.threads=2
这里的 IntelliJ/JUnit 专家可能知道为什么会发生这种情况?
如果你像我一样是 intellij 的新手。我写了 junits,只想 运行 它们。在eclipse中,你去testclass->右键->运行->as junit。我们有点像这样。它在intellij中也很相似。转到测试 class 右键单击和 运行 作为 junits。 如果这样的选项不可用,那么问题可能出在 file->project structure->module->source 此处您的测试不能配置到您的 repo 的测试文件夹中。 因此,在 project structure->module->sources 中点击 test in module 然后 select the path to test folder 。然后申请->确定。 现在 运行 作为测试选项将在右键单击测试 class 时可用。
您可以在 运行 配置设置中指定相同的 -D
参数。按 "Run"(在 Windows 上按 Alt+Shift+F10,在 Mac 上按 Ctrl+Alt+R),select 您的 运行 配置,向右箭头,编辑:
然后在VM选项下指定所有-D
参数:
之后,选项将传递给 TeaVM 运行ner,就像它与 mvn test
命令一起工作一样。