java - Eclipse Junit run configuration that takes the current selected test class as an arg? -


instead of creating identical debug configuraitons test cases, able save few arguments common across junit tests, right click on specific test, run single run config. ie i single debug configuration can take argument current selected test case instead of requiring me manually specify every time in junit run configuration. options in dialog appear either specify single test class or run tests in project. result, eclipse littered dozens of run configurations test cases.

instead of specifying specific test class, i'd specify variable ${container_loc} or ${resource_loc} class run in this question. there variable in eclipse specifies current selected java class place in test class field in dialog?

a specific example useful when running lucene unit tests. there's lots of arguments can specify customize tests, of -ea required. everytime want test specific test case in lucene in eclipse, have manually setup these variables in eclipse debug config dialog :-/.

have looked @ parameterized tests in junit? here example:

import org.junit.assert; import org.junit.test; import org.junit.runner.runwith; import org.junit.runners.parameterized; import org.junit.runners.parameterized.parameters;  @runwith(parameterized.class) public class paramtest {     @parameters(name = "{index}: fib({0})={1}")     public static iterable<object[]> data() {         return arrays.aslist(new object[][] {                   { 0, 0 }, { 1, 1 }, { 2, 1 }, { 3, 2 }, { 4, 3 }, { 5, 5 }, { 6, 8 }            });     }      private int input;     private int expected;      public paramtest(int input, int expected) {         this.input = input;         this.expected = expected;     }      @test     public void test() {         assert.assertequals(expected, input);     } } 

if want run 1 test @ time can use private variables in:

    public class multipletest {     private int x;     private int y;      public void test1(){         assert.assertequals(x, y);     }     public void test2(){         assert.asserttrue(x  >y);     }      public void args1(){         x=10; y=1;     }     public void args2(){         x=1;y=1;     }     public void args3(){         x=1;y=10;     }     @test     public void testargs11(){         args1();         test1();     }     @test     public void testargs21(){         args2();         test1();     }     @test     public void testargs31(){         args3();         test1();     }     @test     public void testargs12(){         args1();         test2();     }     @test     public void testargs22(){         args2();         test2();     }     @test     public void testargs32(){         args3();         test2();     } } 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -