11package com .github .mustachejavabenchmarks ;
22
33import com .github .mustachejava .*;
4- import junit .framework .TestCase ;
4+ import org .junit .Before ;
5+ import org .junit .Test ;
56
67import java .io .File ;
78import java .io .IOException ;
1516 * Date: 5/14/11
1617 * Time: 9:28 PM
1718 */
18- public class BenchmarkTest extends TestCase {
19+ public class BenchmarkTest {
1920 private static final int TIME = 2000 ;
2021 protected File root ;
2122
22- protected void setUp () throws Exception {
23- super . setUp ();
23+ @ Before
24+ public void setUp () throws Exception {
2425 File file = new File ("src/test/resources" );
2526 root = new File (file , "simple.html" ).exists () ? file : new File ("../src/test/resources" );
26-
2727 }
2828
2929 public static boolean skip () {
3030 return System .getenv ().containsKey ("CI" ) || System .getProperty ("CI" ) != null ;
3131 }
3232
33+ @ Test
3334 public void testCompiler () {
3435 if (skip ()) return ;
3536 System .out .println ("complex.html compilations per second:" );
@@ -48,6 +49,7 @@ public void testCompiler() {
4849 }
4950 }
5051
52+ @ Test
5153 public void testComplex () throws MustacheException , IOException {
5254 if (skip ()) return ;
5355 System .out .println ("complex.html evaluations per millisecond:" );
@@ -73,6 +75,7 @@ protected DefaultMustacheFactory createMustacheFactory() {
7375 return new DefaultMustacheFactory ();
7476 }
7577
78+ @ Test
7679 public void testComplexFlapping () throws MustacheException , IOException {
7780 if (skip ()) return ;
7881 System .out .println ("complex.html evaluations with 3 different objects per millisecond:" );
@@ -96,6 +99,7 @@ public void testComplexFlapping() throws MustacheException, IOException {
9699 }
97100 }
98101
102+ @ Test
99103 public void testParallelComplex () throws MustacheException , IOException {
100104 if (skip ()) return ;
101105 System .out .println ("complex.html evaluations per millisecond:" );
@@ -117,6 +121,7 @@ public void testParallelComplex() throws MustacheException, IOException {
117121 }
118122 }
119123
124+ @ Test
120125 public void testParallelComplexNoExecutor () throws MustacheException , IOException {
121126 if (skip ()) return ;
122127 System .out .println ("complex.html evaluations per millisecond:" );
@@ -142,14 +147,4 @@ private Writer complextest(Mustache m, Object complexObject) throws MustacheExce
142147 m .execute (sw , complexObject ).close ();
143148 return sw ;
144149 }
145-
146- public static void main (String [] args ) throws Exception {
147- BenchmarkTest benchmarkTest = new BenchmarkTest ();
148- benchmarkTest .setUp ();
149- benchmarkTest .testComplex ();
150- benchmarkTest .testParallelComplex ();
151- benchmarkTest .testParallelComplexNoExecutor ();
152- System .exit (0 );
153- }
154-
155150}
0 commit comments