Installing Junit with a Caliper

I am trying to wrap caliper code in junit so that performance tests run as part of my unit tests. It seems to work - the caliper test actually runs, but it does not exit successfully. What is the correct way to install this material?

import static org.junit.Assert.*; import org.junit.Test; import com.google.caliper.Runner; import com.google.caliper.SimpleBenchmark; public class CaliperBenchmarkExample extends SimpleBenchmark { public void timeNanoTime(int reps) { for (int i = 0; i < reps; i++) { System.nanoTime(); } } @Test public void testPerformance() { Runner.main(CaliperBenchmarkExample.class, new String[] { }); assertTrue(true); } } 
+4
source share
1 answer

There is no mechanism to run Caliper tests like JUnit tests. It is difficult to do this because the caliper pushes a child process to isolate your tests. And Caliper tests tend to run for a few seconds, which can damage test performance.

You can learn caliper-ci , an open source project that runs Caliper tests continuously.

+4
source

Source: https://habr.com/ru/post/1400638/


All Articles