I would like a simple way to assign a priority value to my JUnit tests, so that I can say "run only tests with priority 1", "run priority 1, 2, and 3 tests", etc. I know that I can just include a string like Assume.assumeTrue("Test skipped for priority " + priority, priority <= 2); at the beginning of each test (where priority is the tests with the highest priority value that I want to run, and 2 is the priority value of this particular test), however, copying to the line at the beginning of each test does not seem to be a very good solution.
I tried to write a solution using the simple annotation found in the JUnit rule that I use:
public class Tests { @Rule public TestRules rules = new TestRules(); @Test @Priority(2) public void test1() {
While this works (the correct tests appear to be skipped in the Eclipse JUnit view), the tests are still running, that is, the test1() code is still running.
Does anyone know how I can get Assume in my rule to skip a test?
source share