All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.umd.cs.findbugs.test.SpotBugsExtension Maven / Gradle / Ivy

There is a newer version: 4.8.6
Show newest version
package edu.umd.cs.findbugs.test;

import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.ParameterContext;
import org.junit.jupiter.api.extension.ParameterResolutionException;
import org.junit.jupiter.api.extension.ParameterResolver;

/**
 * 

A JUnit extension for SpotBugs plugin. * It provides {@link SpotBugsRunner} instance as parameter of test method.

*

Sample code:

*
@ExtendWith(SpotBugsExtension.class)
public class SampleTest {
  @Test
  public void test(SpotBugsRunner spotbugs) {
    BugCollection bugs = spotbugs.performAnalysis(Paths.get("target/test-classes/pkg/GoodCase.class"));
    ...
  }
}
*/ public class SpotBugsExtension implements ParameterResolver { @Override public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException { return parameterContext.getParameter().getType().equals(SpotBugsRunner.class); } @Override public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException { return new SpotBugsRunner(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy