[英]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 中,你去 test class-> right click -> run-> as junit 。 有點像我們這樣做。 它在intellij中也很相似。 轉到測試類,右鍵單擊並作為 junit 運行。 如果這樣的選項不可用,那么問題可能出在文件->項目結構->模塊->源這里你的測試不能被配置到你的repo的測試文件夾中。 因此,在項目結構-> 模塊-> 源中單擊模塊中的測試,然后選擇測試文件夾的路徑。 然后申請-> 好的。 現在運行作為測試選項將在右鍵單擊測試類時可用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.