使用IntelliJ运行JUnit测试

使用IntelliJ运行JUnit测试

本文介绍了使用IntelliJ运行JUnit测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在使用IntelliJ 2018.1,并且尝试运行 TeaVM JUnit测试,但是从以下位置运行测试时 CTRL + SHIFT + F10 测试已被跳过:

I'm using IntelliJ 2018.1 and I am trying to run a TeaVM JUnit test but when running the test from CTRL + SHIFT + F10 tests are getting skipped:

@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());
    }

}

但是当使用以下命令从终端运行时,它可以工作:

But when running from terminal using this command below, it works:

mvn test -Dteavm.junit.target=target/js-tests -Dteavm.junit.js.runner=h
tmlunit -Dteavm.junit.js.threads=2

这里的任何IntelliJ/JUnit专家可能都知道为什么会发生这种情况?

Any IntelliJ/JUnit expert here that may have some idea why is this happening?

推荐答案

您可以在运行配置设置"中指定相同的-D参数.按运行"(在Windows上为Alt + Shift + F10,在Mac上为Ctrl + Alt + R),选择运行配置,向右箭头,

You can specify the same -D parameters in Run configuration settings. Press "Run" (Alt+Shift+F10 on Windows, Ctrl+Alt+R on Mac), select your run configuration, Right arrow,

然后在VM选项下指定所有-D参数:

Then specify all -D parameters under VM options:

之后,这些选项将被传递给TeaVM Runner,就像它与mvn test命令一样.

After that, the options will be passed to TeaVM Runner just like it works with mvn test command.

这篇关于使用IntelliJ运行JUnit测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 22:49