/** * Add a listener to be notified as the tests run. * * @param listener the listener to add * @see org.junit.runner.notification.RunListener */ public void addListener(RunListener listener) { notifier.addListener(listener); }
/** * Add a listener to be notified as the tests run. * * @param listener the listener to add * @see org.junit.runner.notification.RunListener */ public void addListener(RunListener listener) { fNotifier.addListener(listener); }
@Override public void run(RunNotifier notifier) { RunListener listener = new RunListener() { WarningsCollector warningsCollector; @Override public void testStarted(Description description) throws Exception { warningsCollector = new WarningsCollector(); } @Override public void testFailure(Failure failure) throws Exception { logger.log(warningsCollector.getWarnings()); } }; notifier.addListener(listener); runner.run(notifier); }
public RunNotifier getNotifier(final TestResult result, final JUnit4TestAdapter adapter) { RunNotifier notifier = new RunNotifier(); notifier.addListener(new RunListener() { @Override public void testFailure(Failure failure) throws Exception { result.addError(asTest(failure.getDescription()), failure.getException()); } @Override public void testFinished(Description description) throws Exception { result.endTest(asTest(description)); } @Override public void testStarted(Description description) throws Exception { result.startTest(asTest(description)); } }); return notifier; }
@Override public void run(RunNotifier notifier) { RunListener listener = new RunListener() { WarningsCollector warningsCollector; @Override public void testStarted(Description description) throws Exception { warningsCollector = new WarningsCollector(); } @Override public void testFailure(Failure failure) throws Exception { logger.log(warningsCollector.getWarnings()); } }; notifier.addListener(listener); runner.run(notifier); }
public RunNotifier getNotifier(final TestResult result, final JUnit4TestAdapter adapter) { RunNotifier notifier = new RunNotifier(); notifier.addListener(new RunListener() { @Override public void testFailure(Failure failure) throws Exception { result.addError(asTest(failure.getDescription()), failure.getException()); } @Override public void testFinished(Description description) throws Exception { result.endTest(asTest(description)); } @Override public void testStarted(Description description) throws Exception { result.startTest(asTest(description)); } }); return notifier; }
notifier.addListener(listener); super.run(notifier);
public void run(final RunNotifier notifier) { // add listener that validates framework usage at the end of each test notifier.addListener(new FrameworkUsageValidator(notifier)); runner.run(notifier); }
public void run(RunNotifier notifier) { // add listener that validates framework usage at the end of each test notifier.addListener(new FrameworkUsageValidator(notifier)); runner.run(notifier); }
@Before public void setUp() throws Exception { notifier = new RunNotifier(); events = new ArrayList<>(); notifier.addListener(new MyRunListener()); priorEnabledSdks = System.getProperty("robolectric.enabledSdks"); System.clearProperty("robolectric.enabledSdks"); priorAlwaysInclude = System.getProperty("robolectric.alwaysIncludeVariantMarkersInTestName"); System.clearProperty("robolectric.alwaysIncludeVariantMarkersInTestName"); sdkCollection = new SdkCollection(new DefaultSdkProvider(null)); }
@Override protected void runChild(Runner runner, RunNotifier notifier) { notifier.addListener(new OurListener()); super.runChild(runner, notifier); }
@Before public void setUp() { numSupportedApis = APIS_FOR_TEST.length; runListener = new MyRunListener(); runNotifier = new RunNotifier(); runNotifier.addListener(runListener); sdkCollection = new SdkCollection(() -> map(APIS_FOR_TEST)); delegateSdkPicker = new DefaultSdkPicker(sdkCollection, null); priorResourcesMode = System.getProperty("robolectric.resourcesMode"); System.setProperty("robolectric.resourcesMode", "legacy"); priorAlwaysInclude = System.getProperty("robolectric.alwaysIncludeVariantMarkersInTestName"); System.clearProperty("robolectric.alwaysIncludeVariantMarkersInTestName"); }
@Nonnull public static List<Failure> runTests(Class<?> testClass) throws InitializationError { RunNotifier notifier = new RunNotifier(); FailureListener failureListener = new FailureListener(); notifier.addListener(failureListener); new RobolectricTestRunner(testClass).run(notifier); return failureListener.failures; }
private Result run(Runner runner) throws InitializationError { RunNotifier notifier = new RunNotifier(); Result result = new Result(); notifier.addListener(result.createListener()); runner.run(notifier); return result; }
public void run(RunNotifier notifier) { //TODO need to be able to opt in for full stack trace instead of just relying on the stack trace filter UnnecessaryStubbingsReporter reporter = new UnnecessaryStubbingsReporter(); FailureDetector listener = new FailureDetector(); Mockito.framework().addListener(reporter); try { // add listener that detects test failures notifier.addListener(listener); runner.run(notifier); } finally { Mockito.framework().removeListener(reporter); } if (!filterRequested && listener.isSuccessful()) { //only report when: //1. if all tests from given test have ran (filter requested is false) // Otherwise we would report unnecessary stubs even if the user runs just single test from the class //2. tests are successful (we don't want to add an extra failure on top of any existing failure, to avoid confusion) reporter.validateUnusedStubs(testClass, notifier); } }
/** * Add a listener to be notified as the tests run. * * @param listener the listener to add * @see org.junit.runner.notification.RunListener */ public void addListener(RunListener listener) { fNotifier.addListener(listener); }
public class MyJUnit4Runner extends BlockJUnit4ClassRunner { public MyJUnit4Runner(Class<?> clazz) throws InitializationError { super(clazz); } @Override public void run(RunNotifier notifier) { notifier.addListener(new PrintIgnoreRunListener()); super.run(notifier); } }
private List<String> runAndGetFailures(Class<TestWithConfig> testClass) throws InitializationError { RunNotifier notifier = new RunNotifier(); FailureListener failureListener = new FailureListener(); notifier.addListener(failureListener); HierarchicalConfigurationStrategy configurationStrategy = new HierarchicalConfigurationStrategy( new ConfigConfigurer(new PackagePropertiesLoader()), new SomeConfigConfigurer()); SingleSdkRobolectricTestRunner testRunner = new SingleSdkRobolectricTestRunner( testClass, SingleSdkRobolectricTestRunner.defaultInjector() .bind(ConfigurationStrategy.class, configurationStrategy) .build()); testRunner.run(notifier); return failureListener.failures.stream().map(Failure::getMessage).collect(toList()); }
Runner runner = (Runner) BeanUtils.instantiateClass(constructor, testClass); RunNotifier notifier = new RunNotifier(); notifier.addListener(listener); runner.run(notifier);
public RunNotifier getNotifier(final TestResult result, final JUnit4TestAdapter adapter) { RunNotifier notifier = new RunNotifier(); notifier.addListener(new RunListener() { @Override public void testFailure(Failure failure) throws Exception { result.addError(asTest(failure.getDescription()), failure.getException()); } @Override public void testFinished(Description description) throws Exception { result.endTest(asTest(description)); } @Override public void testStarted(Description description) throws Exception { result.startTest(asTest(description)); } }); return notifier; }