本文整理汇总了Java中org.junit.runner.notification.RunNotifier.fireTestFailure方法的典型用法代码示例。如果您正苦于以下问题:Java RunNotifier.fireTestFailure方法的具体用法?Java RunNotifier.fireTestFailure怎么用?Java RunNotifier.fireTestFailure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.junit.runner.notification.RunNotifier
的用法示例。
在下文中一共展示了RunNotifier.fireTestFailure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runChild
import org.junit.runner.notification.RunNotifier; //导入方法依赖的package包/类
@Override
protected void runChild(final ArchTestExecution child, final RunNotifier notifier) {
ExpectedViolation expectedViolation = ExpectedViolation.none();
HandlingAssertion handlingAssertion = HandlingAssertion.none();
Description description = describeChild(child);
notifier.fireTestStarted(description);
try {
ExpectedViolationDefinition violationDefinition = extractExpectedConfiguration(child);
violationDefinition.configure(expectedViolation);
violationDefinition.configure(handlingAssertion);
expectedViolation.apply(new IntegrationTestStatement(child, handlingAssertion), description).evaluate();
} catch (Throwable throwable) {
notifier.fireTestFailure(new Failure(description, throwable));
} finally {
notifier.fireTestFinished(description);
}
}
示例2: run
import org.junit.runner.notification.RunNotifier; //导入方法依赖的package包/类
@Override
public void run(final RunNotifier notifier) {
ClassRoadie classRoadie = new ClassRoadie(notifier, getTestClass(), getDescription(), new Runnable() {
public void run() {
runMethods(notifier);
}
});
Unitils.getInstance().getTestContext().setRunner(this);
try {
getTestListener().beforeTestClass(getTestClass().getJavaClass());
classRoadie.runProtected();
} catch (Throwable t) {
notifier.fireTestFailure(new Failure(getDescription(), t));
}
}
示例3: handleAssertionFailed
import org.junit.runner.notification.RunNotifier; //导入方法依赖的package包/类
Boolean handleAssertionFailed(RunNotifier notifier,
Description description,
String scenarioName,
String stepName,
List<AssertionReport> failureReportList) {
/**
* Generate error report and display clearly which expectation(s) did not match
*/
logger.info(String.format("Failed assertion during Scenario:%s, --> Step:%s, Details: %s\n",
scenarioName, stepName, StringUtils.join(failureReportList, "\n")));
notifier.fireTestFailure(new Failure(description, new RuntimeException(
String.format("Assertion failed for :- \n\n[%s] \n\t|\n\t|\n\t+---Step --> [%s] \n\nFailures:\n--------- %n%s%n",
scenarioName,
stepName,
StringUtils.join(failureReportList, "\n" + deckedUpLine(maxEntryLengthOf(failureReportList)) + "\n"))
)));
return false;
}
示例4: run
import org.junit.runner.notification.RunNotifier; //导入方法依赖的package包/类
@Override
public void run(RunNotifier notifier) {
Description description = getDescription();
notifier.fireTestStarted(description);
notifier.fireTestFailure(new Failure(description, failure));
notifier.fireTestFinished(description);
}
示例5: runChild
import org.junit.runner.notification.RunNotifier; //导入方法依赖的package包/类
@Override
protected void runChild(TestCases.TestCase testCase, RunNotifier runNotifier) {
Description description = this.children.get( testCase );
try {
runNotifier.fireTestStarted( description );
vendorSuite.beforeTest( description, context, testCase );
TestResult result = vendorSuite.executeTest( description, context, testCase );
switch ( result.getResult() ) {
case SUCCESS:
runNotifier.fireTestFinished( description );
break;
case IGNORED:
runNotifier.fireTestIgnored( description );
break;
case ERROR:
runNotifier.fireTestFailure(new Failure(description, new RuntimeException(result.toStringWithLines())));
break;
}
if (resultFile != null) {
String relativePath = relativePath(folder);
resultFile.append( String.format( "\"%s\",\"%s\",\"%s\",\"%s\",\"%s\"\n", relativePath, description.getClassName(), description.getMethodName(),
result.getResult().toString(), result.getMsg() ) );
}
} catch ( IOException e ) {
e.printStackTrace();
} finally {
vendorSuite.afterTest( description, context, testCase );
runNotifier.fireTestFinished(description);
}
}
示例6: testJSJVMBackendFrameworkMethod
import org.junit.runner.notification.RunNotifier; //导入方法依赖的package包/类
private void testJSJVMBackendFrameworkMethod(FrameworkMethod aFrameworkMethod, RunNotifier aRunNotifier) {
Description theDescription = Description.createTestDescription(testClass.getJavaClass(), aFrameworkMethod.getName() + " JVM Target");
aRunNotifier.fireTestStarted(theDescription);
try {
// Simply invoke using reflection
Object theInstance = testClass.getJavaClass().getDeclaredConstructor().newInstance();
Method theMethod = aFrameworkMethod.getMethod();
theMethod.invoke(theInstance);
aRunNotifier.fireTestFinished(theDescription);
} catch (Exception e) {
aRunNotifier.fireTestFailure(new Failure(theDescription, e));
}
}
示例7: runChildAfter
import org.junit.runner.notification.RunNotifier; //导入方法依赖的package包/类
static void runChildAfter(final BlockJUnit4ClassRunner runner, final FrameworkMethod method,
final RunNotifier notifier, final LogExecutionTime logExecutionTime) {
LOGGER.info("<<< %s took %s", method.getMethod(), logExecutionTime);
if (StroomJunitConsoleAppender.getUnexpectedExceptions().size() > 0) {
notifier.fireTestFailure(new Failure(
Description.createTestDescription(runner.getTestClass().getJavaClass(), method.getName()),
StroomJunitConsoleAppender.getUnexpectedExceptions().get(0)));
}
StroomJunitConsoleAppender.setExpectedException(null);
}
示例8: shutdownRerun
import org.junit.runner.notification.RunNotifier; //导入方法依赖的package包/类
private void shutdownRerun(RunNotifier notifier) {
double percentageOfFailedTests = statisticsHelper.getPercentageOfFailedTests(statisticsFile);
int failedTestsNumber = statisticsHelper.getNumberOfFailedTests(statisticsFile);
if (failedTestsNumber == 0) {
notifier.fireTestFinished(Description.EMPTY);
} else if (percentageOfFailedTests > maxFailedTestPercentage) {
String failureMessage = "Percentage of failed tests was bigger than " + maxFailedTestPercentage + ".";
Failure failure = new Failure(Description.createSuiteDescription(failureMessage),
new TooManyTestsToRerunException(failureMessage));
notifier.fireTestFailure(failure);
}
}
示例9: run
import org.junit.runner.notification.RunNotifier; //导入方法依赖的package包/类
@Override
public void run(RunNotifier notifier) {
if (failure != null) {
reportInitializationFailure(notifier, description, failure);
return;
}
for (Map.Entry<String, Description> entry : tests.entrySet()) {
Description testDescription = entry.getValue();
FileTester tester;
try {
tester = createTester(entry.getKey());
} catch (IOException e) {
reportInitializationFailure(notifier, testDescription, e);
continue;
}
if (tester == null) {
notifier.fireTestIgnored(testDescription);
continue;
}
notifier.fireTestStarted(testDescription);
try {
tester.runTest();
} catch (Throwable t) {
notifier.fireTestFailure(new Failure(testDescription, t));
}
notifier.fireTestFinished(testDescription);
}
}
示例10: runChild
import org.junit.runner.notification.RunNotifier; //导入方法依赖的package包/类
@Override
protected void runChild(Postcondition postcondition, RunNotifier notifier) {
try {
clausesFor(postcondition).filter(Clause::isPrecondition).forEachOrdered(Clause::run);
clausesFor(postcondition).filter(Clause::isSpecification).forEachOrdered(Clause::run);
postcondition.verify();
} catch (AssertionError|SpecificationError e) {
notifier.fireTestFailure(new Failure(cache.get(postcondition), e));
}
}
示例11: run
import org.junit.runner.notification.RunNotifier; //导入方法依赖的package包/类
public void run(RunNotifier notifier) {
for (JmesPathComplianceTest.ComplianceTest<T> complianceTest : getAllTests()) {
Description testDescription = createDescription(complianceTest);
notifier.fireTestStarted(testDescription);
try {
complianceTest.run();
} catch (AssertionError ae) {
notifier.fireTestFailure(new Failure(testDescription, ae));
} catch (Exception e) {
notifier.fireTestFailure(new Failure(testDescription, e));
} finally {
notifier.fireTestFinished(testDescription);
}
}
}
示例12: runChild
import org.junit.runner.notification.RunNotifier; //导入方法依赖的package包/类
@Override
protected void runChild(FrameworkMethod method, RunNotifier notifier) {
try {
resolveFailureCollectorRule(method);
notifier.addFirstListener(new FailureListener(failureCollector));
} catch (Exception e) {
notifier.fireTestFailure(new Failure(createTestDescription(method.getDeclaringClass(), method.getName()), e));
}
super.runChild(method, notifier);
}
示例13: run
import org.junit.runner.notification.RunNotifier; //导入方法依赖的package包/类
@Override
public void run( final RunNotifier notifier )
{
for ( final ScriptTestInstance file : this.testFiles )
{
for ( final ScriptTestMethod method : file.getTestMethods() )
{
final Description desc = Description.createTestDescription( file.getName(), method.getName() );
notifier.fireTestStarted( desc );
try
{
runBefore( file );
method.runTest( this.testInstance );
runAfter( file );
}
catch ( final Throwable e )
{
notifier.fireTestFailure( new Failure( desc, e ) );
}
finally
{
notifier.fireTestFinished( desc );
}
}
file.dispose();
}
}
示例14: handleStepException
import org.junit.runner.notification.RunNotifier; //导入方法依赖的package包/类
Boolean handleStepException(RunNotifier notifier,
Description description,
String scenarioName,
String stepName,
Exception stepException) {
logger.info(String.format("Exception occurred while executing Scenario:[%s], --> Step:[%s], Details: %s",
scenarioName, stepName, stepException));
notifier.fireTestFailure(new Failure(description, stepException));
return false;
}
示例15: runChild
import org.junit.runner.notification.RunNotifier; //导入方法依赖的package包/类
@Override
protected void runChild(final FrameworkMethod method, final RunNotifier notifier) {
try {
try {
ThreadScopeContextHolder.createContext();
TaskScopeContextHolder.addContext();
final LogExecutionTime logExecutionTime = new LogExecutionTime();
try {
StroomJUnit4ClassRunner.runChildBefore(this, method, notifier);
super.runChild(method, notifier);
} finally {
StroomJUnit4ClassRunner.runChildAfter(this, method, notifier, logExecutionTime);
}
} finally {
TaskScopeContextHolder.removeContext();
ThreadScopeContextHolder.destroyContext();
}
while (TaskScopeContextHolder.contextExists()) {
notifier.fireTestFailure(
new Failure(Description.createTestDescription(getTestClass().getJavaClass(), method.getName()),
new RuntimeException("Context stills exists?")));
TaskScopeContextHolder.removeContext();
}
} catch (final Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}