Unable to implement Junits using JMH

Viewed 96

Unable to add test cases in the following class

import org.junit.Test;//Line 7
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.options.*;

public class MyBenchmark 
{
      @Test // Line 17
      public void launchBenchmark() throws Exception {

            Options opt = new OptionsBuilder()
                .include(this.getClass().getName() + ".*")
                .mode (Mode.AverageTime)
                .timeUnit(TimeUnit.MICROSECONDS)
                .warmupTime(TimeValue.seconds(1))
                .warmupIterations(2)
                .measurementTime(TimeValue.seconds(1))
                .measurementIterations(2)
                .threads(2)
                .forks(1)
                .shouldFailOnError(true)
                .shouldDoGC(true)
                .build();

            new Runner(opt).run();
        }

      @Benchmark
      public void benchmark1 () {
            int a = 5;
            int b = 10;
            int sum = a + b;
        }
}

While building the JAR file, it is showing the following compilation errors

[ERROR] /C:/benchmark/src/main/java/com/example/MyBenchmark.java:[7,17] package org.junit does not exist [ERROR] /C:/benchmark/src/main/java/com/example/MyBenchmark.java:[17,8] cannot find symbol [ERROR] symbol: class Test [ERROR] location: class com.example.MyBenchmark

I am using dependencies like jmh-core,jmh-generator-annprocess and junit-4.13.1

Any help is highly appreciated

0 Answers
Related