JUnit parameterized tests: how do I run only 1 specific test from IntelliJ/Eclipse?

前端 未结 5 952
名媛妹妹
名媛妹妹 2021-02-03 20:06

I have a @Parameterized junit test that spawns 50 tests:

@RunWith(Parameterized.class)
public class NurseRosteringSolveAllTurtleTest ... {

    @Par         


        
5条回答
  •  孤城傲影
    2021-02-03 21:02

    I just tested this in Eclipse with a simple parameterized test that always fails on test #4. One is able to right-click on the failed test and select Run. Only that test then executes.

    test output

    Result:

    just test 4

    Frustratingly, I can't see what Eclipse did to solve the problem. Nothing is apparently altered in the run configuration. In particular, if you select to run the configuration a second time, it executes all the tests.

    Some further testing shows that Eclipse will regenerate all 10 parameter values, but only uses the 4th value. (This was determined by embedding a print statement in the @Parameters method).

提交回复
热议问题