View Javadoc
1   package org.junit.tests.experimental.theories.runner;
2   
3   import static org.junit.Assert.assertThat;
4   import static org.junit.Assume.assumeTrue;
5   import static org.junit.experimental.results.PrintableResult.testResult;
6   import static org.junit.experimental.results.ResultMatchers.isSuccessful;
7   
8   import org.junit.Test;
9   import org.junit.experimental.theories.DataPoints;
10  import org.junit.experimental.theories.Theories;
11  import org.junit.experimental.theories.Theory;
12  import org.junit.runner.RunWith;
13  
14  public class TheoriesPerformanceTest {
15      @RunWith(Theories.class)
16      public static class UpToTen {
17          @DataPoints
18          public static int[] ints = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
19  
20          @Theory
21          public void threeInts(int x, int y, int z) {
22              // pass always
23          }
24      }
25  
26      private static final boolean TESTING_PERFORMANCE = false;
27  
28      // If we do not share the same instance of TestClass, repeatedly parsing the
29      // class's annotations looking for @Befores and @Afters gets really costly.
30      //
31      // Likewise, the TestClass must be passed into AllMembersSupplier, or the
32      // annotation parsing is again costly.
33      @Test
34      public void tryCombinationsQuickly() {
35          assumeTrue(TESTING_PERFORMANCE);
36          assertThat(testResult(UpToTen.class), isSuccessful());
37      }
38  }