Java Code Examples for org.junit.runner.notification.RunNotifier#fireTestIgnored()

The following examples show how to use org.junit.runner.notification.RunNotifier#fireTestIgnored() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FilteredTestRunner.java    From beanshell with Apache License 2.0 6 votes vote down vote up
@Override
    protected void runChild(final FrameworkMethod method, RunNotifier notifier) {
        Description description= describeChild(method);
        final Category category = method.getAnnotation(Category.class);
        if (category != null) {
            final Class<?>[] value = category.value();
            for (final Class<?> categoryClass : value) {
                if (TestFilter.class.isAssignableFrom(categoryClass)) {
                    final TestFilter testFilter = (TestFilter) Reflect.getNewInstance(categoryClass);
                    if (testFilter.skip()) {
                        notifier.fireTestIgnored(description);
//                            System.out.println("skipping test " + method.getMethod() + " due filter " + categoryClass.getSimpleName());
                        return;
                    }
                }
            }
        }
        runLeaf(methodBlock(method), description, notifier);
    }
 
Example 2
Source File: ZeroCodeUnitRunner.java    From zerocode with Apache License 2.0 6 votes vote down vote up
@Override
protected void runChild(FrameworkMethod method, RunNotifier notifier) {

    final Description description = describeChild(method);
    JsonTestCase jsonTestCaseAnno = method.getMethod().getAnnotation(JsonTestCase.class);
    if(jsonTestCaseAnno == null){
        jsonTestCaseAnno = evalScenarioToJsonTestCase(method.getMethod().getAnnotation(Scenario.class));
    }

    if (isIgnored(method)) {

        notifier.fireTestIgnored(description);

    } else if (jsonTestCaseAnno != null) {

        runLeafJsonTest(notifier, description, jsonTestCaseAnno);

    } else {
        // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
        // It is an usual Junit test, not the JSON test case
        // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
        runLeafJUnitTest(methodBlock(method), description, notifier);
    }

}
 
Example 3
Source File: StandaloneHiveRunner.java    From HiveRunner with Apache License 2.0 6 votes vote down vote up
@Override
protected void runChild(FrameworkMethod method, RunNotifier notifier) {
    Description description = describeChild(method);
    if (method.getAnnotation(Ignore.class) != null) {
        notifier.fireTestIgnored(description);
    } else {
        setLogContext(method);
        EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description);
        eachNotifier.fireTestStarted();
        try {
            runTestMethod(method, eachNotifier, config.getTimeoutRetries());
        } finally {
            eachNotifier.fireTestFinished();
            clearLogContext();
        }
    }
}
 
Example 4
Source File: OleasterRunner.java    From oleaster with Apache License 2.0 6 votes vote down vote up
@Override
protected void runChild(Spec spec, RunNotifier notifier) {
	List<Spec> specs = spec.getSuite().getSpecs();
	boolean suiteHasNoSpecs = specs.isEmpty();
	boolean isFirstSpec = specs.indexOf(spec) == 0;
	boolean isLastSpec = specs.indexOf(spec) == specs.size() -1;

	if (suiteHasNoSpecs || isFirstSpec){
		runBeforeCallbacks(spec);
	}

	if (spec.getBlock().isPresent()) {
		runBeforeEachCallbacks(spec);
		runLeaf(spec, describeChild(spec), notifier);
		runAfterEachCallbacks(spec);
	} else {
		notifier.fireTestIgnored(describeChild(spec));
	}


	if (suiteHasNoSpecs || isLastSpec){
		runAfterCallbacks(spec);
	}
}
 
Example 5
Source File: GremlinProcessRunner.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
public void runChild(final FrameworkMethod method, final RunNotifier notifier) {
    final Description description = describeChild(method);
    if (this.isIgnored(method)) {
        notifier.fireTestIgnored(description);
    } else {
        final EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description);
        eachNotifier.fireTestStarted();
        boolean ignored = false;
        try {
            this.methodBlock(method).evaluate();
        } catch (AssumptionViolatedException ave) {
            eachNotifier.addFailedAssumption(ave);
        } catch (Throwable e) {
            if (validateForGraphComputer(e)) {
                eachNotifier.fireTestIgnored();
                logger.info(e.getMessage());
                ignored = true;
            } else
                eachNotifier.addFailure(e);
        } finally {
            if (!ignored)
                eachNotifier.fireTestFinished();
        }
    }
}
 
Example 6
Source File: NamedParameterizedRunner.java    From sql-layer with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void runChild(FrameworkMethod method, RunNotifier notifier)
{
    if (expectedToPass(method))
    {
        super.runChild(method, notifier);
    }
    else
    {
        notifier.fireTestIgnored( describeChild(method));
    }
}
 
Example 7
Source File: MetamorphTestRunner.java    From metafacture-core with Apache License 2.0 5 votes vote down vote up
@Override
protected void runChild(final MetamorphTestCase child,
        final RunNotifier notifier) {
    final Description description = describeChild(child);
    if (child.isIgnore()) {
        notifier.fireTestIgnored(description);
    } else {
        runLeaf(child, description, notifier);
    }
}
 
Example 8
Source File: SystemTestRunner.java    From pravega with Apache License 2.0 5 votes vote down vote up
@Override
protected void runChild(final FrameworkMethod method, RunNotifier notifier) {
    Description description = describeChild(method);
    if (isIgnored(method)) {
        notifier.fireTestIgnored(description);
    } else {
        //read the type of testExecutor from system property. This is sent by the gradle task. By default
        //the tests are executed locally.
        TestExecutorType executionType = TestExecutorType.valueOf(getConfig("execType", "LOCAL"));
        //sleep for 15 seconds before running tests, remove once pravega/pravega/issues/1665 is resolved
        Exceptions.handleInterrupted(() -> TimeUnit.SECONDS.sleep(15));
        invokeTest(notifier, executionType, method);
    }
}
 
Example 9
Source File: LoadTimeWeavableTestRunner.java    From rice with Educational Community License v2.0 5 votes vote down vote up
/**
 * Runs the test corresponding to {@code child}, which can be assumed to be
 * an element of the list returned by {@link #getChildren()}.
 * Subclasses are responsible for making sure that relevant test events are
 * reported through {@code notifier}
 */
protected void runChild(final FrameworkMethod method, RunNotifier notifier) {
    this.currentMethod = method.getMethod();
    try {
        Description description = describeChild(method);
        if (method.getAnnotation(Ignore.class) != null) {
            notifier.fireTestIgnored(description);
        } else {
            runLeaf(methodBlock(method), description, notifier);
        }
    } finally {
        this.currentMethod = null;
    }
}
 
Example 10
Source File: ATHJUnitRunner.java    From blueocean-plugin with MIT License 5 votes vote down vote up
@Override
protected void runChild(FrameworkMethod method, RunNotifier notifier) {
    Description description = describeChild(method);
    if (isIgnored(method)) {
        notifier.fireTestIgnored(description);
    } else {
        runTest(methodBlock(method), description, notifier, method.getAnnotation(Retry.class));
    }
}
 
Example 11
Source File: RdfUnitJunitRunner.java    From RDFUnit with Apache License 2.0 5 votes vote down vote up
@Override
protected void runChild(final RdfUnitJunitTestCase child, RunNotifier notifier) {
    if(isIgnored(child)) {
        notifier.fireTestIgnored(describeChild(child));
    } else {
        this.runLeaf(new ShaclResultStatement(rdfUnitJunitStatusTestExecutor, child), describeChild(child), notifier);
    }
}
 
Example 12
Source File: AlfrescoTestRunner.java    From alfresco-sdk with Apache License 2.0 5 votes vote down vote up
@Override
protected void runChild(FrameworkMethod method, RunNotifier notifier) {
    if (areWeRunningInAlfresco()) {
        // Just run the test as normally
        super.runChild(method, notifier);
    } else {
        // We are not running in an Alfresco Server, we need to call one and have it execute the test...
        Description desc = describeChild(method);
        if (method.getAnnotation(Ignore.class) != null) {
            notifier.fireTestIgnored(desc);
        } else {
            callProxiedChild(method, notifier, desc);
        }
    }
}
 
Example 13
Source File: TckTestRunner.java    From smallrye-open-api with Apache License 2.0 5 votes vote down vote up
/**
 * @see org.junit.runners.ParentRunner#runChild(java.lang.Object, org.junit.runner.notification.RunNotifier)
 */
@Override
protected void runChild(final ProxiedTckTest child, final RunNotifier notifier) {
    OpenApiDocument.INSTANCE.set(TckTestRunner.OPEN_API_DOCS.get(child.getTest().getClass()));

    Description description = describeChild(child);
    if (isIgnored(child)) {
        notifier.fireTestIgnored(description);
    } else {
        Statement statement = new Statement() {
            @Override
            public void evaluate() throws Throwable {
                try {
                    Method testMethod = child.getTestMethod();
                    testMethod.invoke(child.getDelegate(), child.getArguments());
                } catch (InvocationTargetException e) {
                    Throwable cause = e.getCause();
                    Test testAnno = child.getTestMethod().getAnnotation(Test.class);
                    Class[] expectedExceptions = testAnno.expectedExceptions();
                    if (expectedExceptions != null && expectedExceptions.length > 0) {
                        Class expectedException = expectedExceptions[0];
                        Assert.assertEquals(expectedException, cause.getClass());
                    } else {
                        throw cause;
                    }
                }
            }
        };
        runLeaf(statement, description, notifier);
    }

}
 
Example 14
Source File: MinVersionTestRunner.java    From phoenix with Apache License 2.0 5 votes vote down vote up
@Override
public void runChild(FrameworkMethod method, RunNotifier notifier) {
    MinVersion methodCondition = method.getAnnotation(MinVersion.class);
    MinVersion classCondition = this.getTestClass().getJavaClass().getAnnotation(MinVersion.class);
    String versionStr = VersionInfo.getVersion();
    int version = VersionUtil.encodeVersion(versionStr);
    if (  (methodCondition == null || version >= VersionUtil.encodeVersion(methodCondition.value()))
       && (classCondition == null || version >= VersionUtil.encodeVersion(classCondition.value()))) {
        super.runChild(method, notifier);
    } else {
        notifier.fireTestIgnored(describeChild(method));
    }
}
 
Example 15
Source File: KurentoBlockJUnit4ClassRunnerWithParameters.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Override
protected void runChild(final FrameworkMethod method, RunNotifier notifier) {
  Description description = describeChild(method);
  if (isIgnored(method)) {
    notifier.fireTestIgnored(description);
  } else {
    runLeaf2(methodBlock(method), description, notifier);
  }
}
 
Example 16
Source File: OrcasParameterizedParallel.java    From orcas with Apache License 2.0 5 votes vote down vote up
@Override
protected void runChild( Runner pRunner, RunNotifier pNotifier )
{
  OrcasBlockJUnit4ClassRunnerWithParameters lOrcasBlockJUnit4ClassRunnerWithParameters = (OrcasBlockJUnit4ClassRunnerWithParameters)pRunner;
  String lTestName = lOrcasBlockJUnit4ClassRunnerWithParameters.testName;

  try
  {
    assumeShouldExecuteTestcase( lTestName );
  }
  catch( AssumptionViolatedException e )
  {
    Description lDescribeChildRunner = describeChild( pRunner );
    pNotifier.fireTestAssumptionFailed( new Failure( lDescribeChildRunner, e ) );
    pNotifier.fireTestIgnored( lDescribeChildRunner );

    for( FrameworkMethod lChildFrameworkMethod : lOrcasBlockJUnit4ClassRunnerWithParameters.getChildren() )
    {
      Description lDescribeChildFrameworkMethod = lOrcasBlockJUnit4ClassRunnerWithParameters.describeChild( lChildFrameworkMethod );

      pNotifier.fireTestAssumptionFailed( new Failure( lDescribeChildFrameworkMethod, e ) );
      pNotifier.fireTestIgnored( lDescribeChildFrameworkMethod );
    }

    return;
  }

  super.runChild( pRunner, pNotifier );
}
 
Example 17
Source File: FlinkStandaloneHiveRunner.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected void runChild(final FrameworkMethod method, RunNotifier notifier) {
	Description description = describeChild(method);
	if (method.getAnnotation(Ignore.class) != null) {
		notifier.fireTestIgnored(description);
	} else {
		EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description);
		eachNotifier.fireTestStarted();
		try {
			runTestMethod(method, eachNotifier);
		} finally {
			eachNotifier.fireTestFinished();
		}
	}
}
 
Example 18
Source File: DefaultServer.java    From quarkus-http with Apache License 2.0 4 votes vote down vote up
@Override
protected void runChild(FrameworkMethod method, RunNotifier notifier) {
    AjpIgnore ajpIgnore = method.getAnnotation(AjpIgnore.class);
    if (ajpIgnore == null) {
        ajpIgnore = method.getMethod().getDeclaringClass().getAnnotation(AjpIgnore.class);
    }
    if (ajp && ajpIgnore != null) {
        if (!ajpIgnore.apacheOnly()) {
            notifier.fireTestIgnored(describeChild(method));
            return;
        }
    }
    if (h2 || h2c || ajp || h2cUpgrade) {
        //h2c-upgrade we still allow HTTP1
        HttpOneOnly httpOneOnly = method.getAnnotation(HttpOneOnly.class);
        if (httpOneOnly == null) {
            httpOneOnly = method.getMethod().getDeclaringClass().getAnnotation(HttpOneOnly.class);
        }
        if (httpOneOnly != null) {
            notifier.fireTestIgnored(describeChild(method));
            return;
        }
        if (h2) {
            assumeAlpnEnabled();
        }
    }
    if (https) {
        HttpsIgnore httpsIgnore = method.getAnnotation(HttpsIgnore.class);
        if (httpsIgnore == null) {
            httpsIgnore = method.getMethod().getDeclaringClass().getAnnotation(HttpsIgnore.class);
        }
        if (httpsIgnore != null) {
            notifier.fireTestIgnored(describeChild(method));
            return;
        }
    }
    if (isProxy()) {
        if (method.getAnnotation(ProxyIgnore.class) != null ||
                method.getMethod().getDeclaringClass().isAnnotationPresent(ProxyIgnore.class) ||
                getTestClass().getJavaClass().isAnnotationPresent(ProxyIgnore.class)) {
            notifier.fireTestIgnored(describeChild(method));
            return;
        }
    }
    try {
        if (runs > 1) {
            Statement statement = methodBlock(method);
            Description description = describeChild(method);
            for (Description desc : description.getChildren()) {
                runLeaf(statement, desc, notifier);
            }
        } else {
            super.runChild(method, notifier);
        }
    } finally {
        TestHttpClient.afterTest();
    }
}
 
Example 19
Source File: SpringJUnit4ClassRunner.java    From spring4-understanding with Apache License 2.0 3 votes vote down vote up
/**
 * Check whether the test is enabled in the current execution environment.
 * <p>This prevents classes with a non-matching {@code @IfProfileValue}
 * annotation from running altogether, even skipping the execution of
 * {@code prepareTestInstance()} methods in {@code TestExecutionListeners}.
 * @see ProfileValueUtils#isTestEnabledInThisEnvironment(Class)
 * @see org.springframework.test.annotation.IfProfileValue
 * @see org.springframework.test.context.TestExecutionListener
 */
@Override
public void run(RunNotifier notifier) {
	if (!ProfileValueUtils.isTestEnabledInThisEnvironment(getTestClass().getJavaClass())) {
		notifier.fireTestIgnored(getDescription());
		return;
	}
	super.run(notifier);
}
 
Example 20
Source File: SpringJUnit4ParameterizedClassRunner.java    From tds with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * Check whether the test is enabled in the first place. This prevents
 * classes with a non-matching <code>&#064;IfProfileValue</code> annotation
 * from running altogether, even skipping the execution of
 * <code>prepareTestInstance()</code> <code>TestExecutionListener</code>
 * methods.
 *
 * @see ProfileValueUtils#isTestEnabledInThisEnvironment(Class)
 * @see org.springframework.test.annotation.IfProfileValue
 * @see org.springframework.test.context.TestExecutionListener
 */
@Override
public void run(RunNotifier notifier) {
  if (!ProfileValueUtils.isTestEnabledInThisEnvironment(getTestClass().getJavaClass())) {
    notifier.fireTestIgnored(getDescription());
    return;
  }
  super.run(notifier);
}