Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm not sure what the impediment is with your "test run parallelization", but you might be able to do this with a rule if you're willing to use a custom "ignore" annotation instead of the JUnit one. The reason for that is that JUnit handles @Ignored tests at the Runner level, specifically in the <a href="https://github.com/KentBeck/junit/blob/r4.10/src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java#L62" rel="nofollow"><code>BlockJUnit4ClassRunner.runChild()</code></a> (by default). If you could find a way to use a custom Runner in Ant, you could come up with one to meet your needs pretty easily, but I don't know if that's easily doable in Ant.</p> <p>As I first mentioned, though, you can easily use a different annotation and a rule to choose which methods to run. I made up a quick <a href="https://github.com/zzantozz/testbed/blob/master/stackoverflow/9611070-toggleable-custom-ignore/src/test/java/rds/junit/ToggleableIgnores.java#L1" rel="nofollow">example of such a rule on github</a>, along with <a href="https://github.com/zzantozz/testbed/blob/master/stackoverflow/9611070-toggleable-custom-ignore/src/test/java/rds/junit/TestToggleableIgnores.java#L1" rel="nofollow">a test that uses it</a>. My little example uses a system property for switching, but you can also obviously make it switch on anything you can think of that you can get your hands on here.</p> <p>You can clone and run this example with:</p> <pre><code>git clone git@github.com:zzantozz/testbed tmp cd tmp mvn test -pl stackoverflow/9611070-toggleable-custom-ignore -q mvn test -pl stackoverflow/9611070-toggleable-custom-ignore -q -D junit.invertIgnores </code></pre> <p>The one downside of this approach that I can think of is that your tests won't get properly marked as "ignored" because that's also done by the <a href="https://github.com/KentBeck/junit/blob/r4.10/src/main/java/org/junit/runners/BlockJUnit4ClassRunner.java#L62" rel="nofollow"><code>BlockJUnit4ClassRunner.runChild()</code></a> method, and if you peek at <a href="https://github.com/KentBeck/junit/blob/r4.10/src/main/java/org/junit/runners/ParentRunner.java#L255" rel="nofollow"><code>ParentRunner.runLeaf()</code></a> (which <code>runChild()</code> delegates to), you'll see that the notifier, which is what you need to report ignored tests, isn't passed down far enough to be used by a Rule. Again, it's something you'd need a custom Runner for.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload