@Test @DisplayName("Annotations on method") public void shouldProcessMethodAnnotations() throws Exception { core.run(Request.aClass(TestWithAnnotations.class)); List<TestResult> testResults = results.getTestResults(); assertThat(testResults) .hasSize(1) .flatExtracting(TestResult::getLabels) .extracting(Label::getValue) .contains( "epic1", "epic2", "epic3", "feature1", "feature2", "feature3", "story1", "story2", "story3", "some-owner" ); }
/** * . * @param args . * @throws ClassNotFoundException . */ public static void main(String... args) throws ClassNotFoundException { int retCode = 0; String resultMessage = "SUCCESS"; String[] classAndMethod = args[0].split("#"); Request request = Request.method(Class.forName(classAndMethod[0]), classAndMethod[1]); Result result = new JUnitCore().run(request); if (!result.wasSuccessful()) { retCode = 1; resultMessage = "FAILURE"; } System.out.println(resultMessage); System.exit(retCode); }
@Override public void runTaskCase() throws Exception { AbstractCaseData.setCaseData(null); String caseDataInfo = this.tcr.getTaskCase().getCaseDataInfo(); if (!caseDataInfo.isEmpty()) { CaseData caseData = AbstractCaseData.getCaseData(caseDataInfo); LOG.debug("Injecting case data: {} = {}", caseDataInfo, caseData.getValue()); AbstractCaseData.setCaseData(caseData); } TaskCase tc = this.tcr.getTaskCase(); LOG.debug("Loading case {}", tc.format()); CaseRunListener trl = new CaseRunListener(this.db, this.tcr); JUnitCore core = new JUnitCore(); core.addListener(trl); core.run(Request.method(Class.forName(tc.getCaseClass()), tc.getCaseMethod())); }
@Override public void start(Stage stage) throws Exception { AppLauncher.getInstance().setRemoteStage(stage); new Thread(new Runnable() { public void run() { try { System.out.println("Running junit"); Result r = new JUnitCore().run(Request.method(Class.forName(className), testName)); System.out.println("got result = " + r.wasSuccessful()); } catch (ClassNotFoundException ex) { ex.printStackTrace(); } finally { //System.exit(0); } } }).start(); }
@Test public void testTextResultPresentation() throws Exception { IResultPresentation presentation = new TextResultPresentation(); final String genericExpected = "" + "Testcase: junit.framework.TestCase.test()" + NEW_LINE + "Mutated method: java.lang.Object.hashCode()" + NEW_LINE + "Return value generator: " + SAMPLE_RET_VAL_GEN_NAME + NEW_LINE + "Result: %s" + NEW_LINE + "."; String output; String expected; Result result; result = new Result(); output = presentation.formatTestResultEntry(SAMPLE_TEST_IDENTIFIER, new JUnitTestRunResult(result), SAMPLE_METHOD_IDENTIFIER, SAMPLE_RET_VAL_GEN_NAME); expected = String.format(genericExpected, "OK"); assertEquals(expected, output); result = new JUnitCore().run(Request.method(SampleJUnitTestClass.class, "b")); output = presentation.formatTestResultEntry(SAMPLE_TEST_IDENTIFIER, new JUnitTestRunResult(result), SAMPLE_METHOD_IDENTIFIER, SAMPLE_RET_VAL_GEN_NAME); expected = String.format(genericExpected, "1 of 1 FAILED" + NEW_LINE + "Exception: java.lang.AssertionError"); assertEquals(expected, output); }
@Test public void testDatabaseResultPresentation() { IResultPresentation presentation = new DatabaseResultPresentation(); presentation.setExecutionId(ExecutionIdFactory.parseShortExecutionId("EXEC")); final String genericExpected = "INSERT INTO Test_Result_Import (execution, testcase, method, retValGen, killed, assertErr, exception) VALUES ('EXEC', 'junit.framework.TestCase.test()', 'java.lang.Object.hashCode()', '%s', %s, %s, '%s');"; String output; String expected; Result result; result = new Result(); output = presentation.formatTestResultEntry(SAMPLE_TEST_IDENTIFIER, new JUnitTestRunResult(result), SAMPLE_METHOD_IDENTIFIER, SAMPLE_RET_VAL_GEN_NAME); expected = String.format(genericExpected, SAMPLE_RET_VAL_GEN_NAME, false, false, ""); assertEquals(expected, output); result = new JUnitCore().run(Request.method(SampleJUnitTestClass.class, "b")); output = presentation.formatTestResultEntry(SAMPLE_TEST_IDENTIFIER, new JUnitTestRunResult(result), SAMPLE_METHOD_IDENTIFIER, SAMPLE_RET_VAL_GEN_NAME); expected = String.format(genericExpected, SAMPLE_RET_VAL_GEN_NAME, true, true, AssertionError.class.getName()); assertEquals(expected, output); }
public static void main(final String[] args) throws Exception { preFlightTest(args); table = args[0]; family = args[1]; TestIntegration.args = args; LOG.info("Starting integration tests"); final JUnitCore junit = new JUnitCore(); final JunitListener listener = new JunitListener(); junit.addListener(listener); final String singleTest = System.getenv("TEST_NAME"); final Request req; if (singleTest != null) { req = Request.method(TestIntegration.class, singleTest); } else { req = Request.aClass(TestIntegration.class); } final Result result = junit.run(req); LOG.info("Ran " + result.getRunCount() + " tests in " + result.getRunTime() + "ms"); if (!result.wasSuccessful()) { LOG.error(result.getFailureCount() + " tests failed: " + result.getFailures()); System.exit(1); } LOG.info("All tests passed!"); }
private static List<JUnit4TestReference> getRequestForClasses(String[] args) { List<JUnit4TestReference> suites = new LinkedList<>(); for (String classFqn : args) { try { Class<?> aClass = Class.forName(classFqn); Request request = Request.aClass(aClass); Runner runner = request.getRunner(); suites.add(new JUnit4TestReference(runner, runner.getDescription())); } catch (ClassNotFoundException ignored) { } } if (suites.isEmpty()) { System.err.print("No test found to run."); return emptyList(); } return suites; }
/** * Wrapper over JUniteCore that runs one test. * * @return the result of the test. * @throws Exception if there was an exception running the test. */ @Override public AugmentedResult call() throws Exception { JUnitCore jUnitCore = getJUnitCore(); String testName = String.format("%s#%s", test.getDeclaringClass().getCanonicalName(), test.getName()); long start = System.currentTimeMillis(); try { LOG.info(String.format("STARTING Test %s", testName)); // HACK since for TestSuiteRunner we want to retry, and for TestMethodRunner we don't want to // The other way would be a RETRY on augmented.properties, but this is independent of the configuration of // the test. if (retry) { TestRunnerRetryingRule.retry(); } Result result = jUnitCore.run(Request.method(test.getDeclaringClass(), test.getName())); LOG.info(String.format("FINSHED Test %s in %s, result %s", testName, Util.TO_PRETTY_FORMAT.apply(System.currentTimeMillis() - start), result.wasSuccessful()? "SUCCEEDED" : "FAILED")); return new AugmentedResult(testName, result, outputStream); } finally { outputStream.close(); } }
private static void execute( Class<?> testClass, Notifier notifier, Filter filter ) throws TestSetFailedException { final int classModifiers = testClass.getModifiers(); if ( !isAbstract( classModifiers ) && !isInterface( classModifiers ) ) { Request request = aClass( testClass ); if ( filter != null ) { request = request.filterWith( filter ); } Runner runner = request.getRunner(); if ( countTestsInRunner( runner.getDescription() ) != 0 ) { executeInPlayContext( runner, notifier ); } } }
private void runTest(Map<String, Bundle> installed, DataInputStream input, DataOutputStream output) throws Exception { String symbolicName = input.readUTF(); Version version = Version.parseVersion(input.readUTF()); String testClass = input.readUTF(); String testName = input.readUTF(); Bundle testBundle = getTestBundle(installed, input, output, symbolicName, version); Class<?> testClazz = testBundle.loadClass(testClass); Result result = new JUnitCore().run(Request.method(testClazz, testName)); if(result.wasSuccessful()) { output.writeUTF(SUCCESS); } else { Failure failure = result.getFailures().get(0); output.writeUTF(FAIL); output.writeUTF(failure.getMessage()); } output.flush(); }
public static void run(Configuration configuration, Class<?> clazz, String methodName) { try { Request request = null; if (clazz!=null && methodName!=null) { request = Request.method(clazz, methodName); } else { Suite suite = new Suite(new JUnit4Builder(), API_TEST_CLASSES); request = Request.runner(suite); } Configuration originalConfiguration = WorkflowTest.cachedConfiguration; WorkflowTest.cachedConfiguration = configuration; JUnitCore junitCore = new JUnitCore(); Result result = junitCore.run(request); WorkflowTest.cachedConfiguration = originalConfiguration; checkResult(result); } catch (Exception e) { throw new RuntimeException(e); } }
public static void main(String []argv) { int maxIterations = 10; JUnitCore junit = new JUnitCore(); Result result = null; int iter = 0; do { result = junit.run(Request.method(TraversalsTests.class, "testDepthFirstOnCircle")); iter++; System.out.println("Failures " + result.getFailureCount()); if (result.getFailureCount() > 0) { for (Failure failure : result.getFailures()) { failure.getException().printStackTrace(); } } } while (result.getFailureCount() == 0 && iter < maxIterations); }
public static void main(String []argv) { JUnitCore junit = new JUnitCore(); Result result = null; do { result = junit.run(Request.method(PropertyIndexingTests.class, "derivedPropertyIndexing")); } while (result.getFailureCount() == 0 && false); System.out.println("Failures " + result.getFailureCount()); if (result.getFailureCount() > 0) { for (Failure failure : result.getFailures()) { failure.getException().printStackTrace(); } } System.exit(0); }
public static void main(String[] args) throws ClassNotFoundException { String arg = "eu.hgross.blaubot.test.AllSuite"; if (args.length > 0) { arg = args[0]; } String[] classAndMethod = arg.split("#"); Request request; if (classAndMethod.length == 1) { request = Request.classes(Class.forName(classAndMethod[0])); } else { request = Request.method(Class.forName(classAndMethod[0]), classAndMethod[1]); } Result result = new JUnitCore().run(request); for (Failure failure : result.getFailures()) { System.out.println(failure.getMessage()); } System.exit(result.wasSuccessful() ? 0 : 1); }
private Request constructLeafRequest(List<Description> leaves) { final List<Runner> runners = new ArrayList<Runner>(); for (Description each : leaves) { runners.add(buildRunner(each)); } return new Request() { @Override public Runner getRunner() { try { return new Suite((Class<?>) null, runners) { }; } catch (InitializationError e) { return new ErrorReportingRunner(null, e); } } }; }
private Runner buildRunner(Description each) { if (each.toString().equals("TestSuite with 0 tests")) { return Suite.emptySuite(); } if (each.toString().startsWith(MALFORMED_JUNIT_3_TEST_CLASS_PREFIX)) { // This is cheating, because it runs the whole class // to get the warning for this method, but we can't do better, // because JUnit 3.8's // thrown away which method the warning is for. return new JUnit38ClassRunner(new TestSuite(getMalformedTestClass(each))); } Class<?> type = each.getTestClass(); if (type == null) { throw new RuntimeException("Can't locate a runner from description [" + each + "]"); } String methodName = each.getMethodName(); if (methodName == null) { return Request.aClass(type).getRunner(); } return Request.method(type, methodName).getRunner(); }
@Test public void testCreateModel_simpleSuite() throws Exception { Class<?> suiteClass = SampleSuite.class; Request request = Request.classWithoutSuiteMethod(suiteClass); String suiteClassName = suiteClass.getCanonicalName(); JUnit4TestModelBuilder modelBuilder = builder( request, suiteClassName, stubShardingEnvironment, null, xmlResultWriter); Description topSuite = request.getRunner().getDescription(); Description innerSuite = topSuite.getChildren().get(0); Description testOne = innerSuite.getChildren().get(0); TestSuiteModel model = modelBuilder.get(); TestNode topSuiteNode = Iterables.getOnlyElement(model.getTopLevelTestSuites()); assertThat(topSuiteNode.getDescription()).isEqualTo(topSuite); TestNode innerSuiteNode = Iterables.getOnlyElement(topSuiteNode.getChildren()); assertThat(innerSuiteNode.getDescription()).isEqualTo(innerSuite); TestNode testOneNode = Iterables.getOnlyElement(innerSuiteNode.getChildren()); assertThat(testOneNode.getDescription()).isEqualTo(testOne); assertThat(testOneNode.getChildren()).isEmpty(); assertThat(model.getNumTestCases()).isEqualTo(1); }
@Test public void assumptionViolationsAtSuiteLevelAreReportedAsSkippedSuite() throws Exception { TestSuiteModelSupplier mockModelSupplier = mock(TestSuiteModelSupplier.class); TestSuiteModel mockModel = mock(TestSuiteModel.class); CancellableRequestFactory mockRequestFactory = mock(CancellableRequestFactory.class); OutputStream mockXmlStream = mock(OutputStream.class); JUnit4TestXmlListener listener = new JUnit4TestXmlListener( mockModelSupplier, mockRequestFactory, fakeSignalHandlers, mockXmlStream, errPrintStream); Request request = Request.classWithoutSuiteMethod( TestWithAssumptionViolationOnTheSuiteLevel.class); Description suiteDescription = request.getRunner().getDescription(); when(mockModelSupplier.get()).thenReturn(mockModel); JUnitCore core = new JUnitCore(); core.addListener(listener); core.run(request); assertWithMessage("no output to stderr expected").that(errStream.size()).isEqualTo(0); InOrder inOrder = inOrder(mockModel); inOrder.verify(mockModel).testSkipped(suiteDescription); inOrder.verify(mockModel).writeAsXml(mockXmlStream); verify(mockRequestFactory, never()).cancelRun(); }
public JUnit4RunnerFactory( Supplier<Request> requestSupplier, Supplier<CancellableRequestFactory> requestFactorySupplier, Supplier<Supplier<TestSuiteModel>> modelSupplierSupplier, Supplier<PrintStream> testRunnerOutSupplier, Supplier<JUnit4Config> configSupplier, Supplier<Set<RunListener>> runListenersSupplier, Supplier<Set<JUnit4Runner.Initializer>> initializersSupplier) { assert requestSupplier != null; this.requestSupplier = requestSupplier; assert requestFactorySupplier != null; this.requestFactorySupplier = requestFactorySupplier; assert modelSupplierSupplier != null; this.modelSupplierSupplier = modelSupplierSupplier; assert testRunnerOutSupplier != null; this.testRunnerOutSupplier = testRunnerOutSupplier; assert configSupplier != null; this.configSupplier = configSupplier; assert runListenersSupplier != null; this.runListenersSupplier = runListenersSupplier; assert initializersSupplier != null; this.initializersSupplier = initializersSupplier; }
@Test public void writesXmlAtTestEnd() throws Exception { TestSuiteModelSupplier mockModelSupplier = mock(TestSuiteModelSupplier.class); TestSuiteModel mockModel = mock(TestSuiteModel.class); CancellableRequestFactory mockRequestFactory = mock(CancellableRequestFactory.class); OutputStream mockXmlStream = mock(OutputStream.class); JUnit4TestXmlListener listener = new JUnit4TestXmlListener( mockModelSupplier, mockRequestFactory, fakeSignalHandlers, mockXmlStream, errPrintStream); when(mockModelSupplier.get()).thenReturn(mockModel); JUnitCore core = new JUnitCore(); core.addListener(listener); core.run(Request.classWithoutSuiteMethod(PassingTest.class)); assertWithMessage("no output to stderr expected").that(errStream.size()).isEqualTo(0); verify(mockModel).writeAsXml(mockXmlStream); verify(mockRequestFactory, never()).cancelRun(); }
@Test public void testDoesNotTouchShardFileWhenShardingDisabled() { Class<?> testClass = SampleTestCaseWithTwoTests.class; Request request = Request.classWithoutSuiteMethod(testClass); ShardingEnvironment mockShardingEnvironment = mock(ShardingEnvironment.class); ShardingFilters shardingFilters = new ShardingFilters( mockShardingEnvironment, DEFAULT_SHARDING_STRATEGY); JUnit4TestModelBuilder modelBuilder = builder( request, testClass.getCanonicalName(), mockShardingEnvironment, shardingFilters, xmlResultWriter); when(mockShardingEnvironment.isShardingEnabled()).thenReturn(false); modelBuilder.get(); verify(mockShardingEnvironment, never()).touchShardFile(); }
public void testOverridingCreateRunner() { final Runner stubRunner = mock(Runner.class); MemoizingRequest memoizingRequest = new MemoizingRequest(mockRequestDelegate) { @Override protected Runner createRunner(Request delegate) { return stubRunner; } }; Runner firstRunner = memoizingRequest.getRunner(); Runner secondRunner = memoizingRequest.getRunner(); assertThat(firstRunner).isSameAs(stubRunner); assertThat(secondRunner).isSameAs(firstRunner); verifyZeroInteractions(mockRequestDelegate); }
@Test public void testCreateModel_singleTestClass() throws Exception { Class<?> testClass = SampleTestCaseWithTwoTests.class; Request request = Request.classWithoutSuiteMethod(testClass); String testClassName = testClass.getCanonicalName(); JUnit4TestModelBuilder modelBuilder = builder( request, testClassName, stubShardingEnvironment, null, xmlResultWriter); Description suite = request.getRunner().getDescription(); Description testOne = suite.getChildren().get(0); Description testTwo = suite.getChildren().get(1); TestSuiteModel model = modelBuilder.get(); TestNode suiteNode = Iterables.getOnlyElement(model.getTopLevelTestSuites()); assertThat(suiteNode.getDescription()).isEqualTo(suite); List<TestNode> testCases = suiteNode.getChildren(); assertThat(testCases).hasSize(2); TestNode testOneNode = testCases.get(0); TestNode testTwoNode = testCases.get(1); assertThat(testOneNode.getDescription()).isEqualTo(testOne); assertThat(testTwoNode.getDescription()).isEqualTo(testTwo); assertThat(testOneNode.getChildren()).isEmpty(); assertThat(testTwoNode.getChildren()).isEmpty(); assertThat(model.getNumTestCases()).isEqualTo(2); }
public static Factory<JUnit4Runner> create( Supplier<Request> requestSupplier, Supplier<CancellableRequestFactory> requestFactorySupplier, Supplier<Supplier<TestSuiteModel>> modelSupplierSupplier, Supplier<PrintStream> testRunnerOutSupplier, Supplier<JUnit4Config> configSupplier, Supplier<Set<RunListener>> runListenersSupplier, Supplier<Set<JUnit4Runner.Initializer>> initializersSupplier) { return new JUnit4RunnerFactory( requestSupplier, requestFactorySupplier, modelSupplierSupplier, testRunnerOutSupplier, configSupplier, runListenersSupplier, initializersSupplier); }
@Test public void testTouchesShardFileWhenShardingEnabled() { Class<?> testClass = SampleTestCaseWithTwoTests.class; Request request = Request.classWithoutSuiteMethod(testClass); ShardingEnvironment mockShardingEnvironment = mock(ShardingEnvironment.class); ShardingFilters shardingFilters = new ShardingFilters( mockShardingEnvironment, DEFAULT_SHARDING_STRATEGY); JUnit4TestModelBuilder modelBuilder = builder( request, testClass.getCanonicalName(), mockShardingEnvironment, shardingFilters, xmlResultWriter); when(mockShardingEnvironment.isShardingEnabled()).thenReturn(true); when(mockShardingEnvironment.getTotalShards()).thenReturn(2); modelBuilder.get(); verify(mockShardingEnvironment).touchShardFile(); }
/** * Creates a runner. */ @Inject JUnit4Runner( Request request, CancellableRequestFactory requestFactory, Supplier<TestSuiteModel> modelSupplier, @Stdout PrintStream testRunnerOut, JUnit4Config config, Set<RunListener> runListeners, Set<Initializer> initializers) { this.request = request; this.requestFactory = requestFactory; this.modelSupplier = modelSupplier; this.config = config; this.testRunnerOut = testRunnerOut; this.runListeners = runListeners; this.initializers = initializers; }
@Test public void failuresAreReported() throws Exception { TestSuiteModelSupplier mockModelSupplier = mock(TestSuiteModelSupplier.class); TestSuiteModel mockModel = mock(TestSuiteModel.class); CancellableRequestFactory mockRequestFactory = mock(CancellableRequestFactory.class); OutputStream mockXmlStream = mock(OutputStream.class); JUnit4TestXmlListener listener = new JUnit4TestXmlListener( mockModelSupplier, mockRequestFactory, fakeSignalHandlers, mockXmlStream, errPrintStream); Request request = Request.classWithoutSuiteMethod(FailingTest.class); Description suiteDescription = request.getRunner().getDescription(); Description testDescription = suiteDescription.getChildren().get(0); when(mockModelSupplier.get()).thenReturn(mockModel); JUnitCore core = new JUnitCore(); core.addListener(listener); core.run(request); assertWithMessage("no output to stderr expected").that(errStream.size()).isEqualTo(0); InOrder inOrder = inOrder(mockModel); inOrder.verify(mockModel).testFailure(eq(testDescription), any(Throwable.class)); inOrder.verify(mockModel).writeAsXml(mockXmlStream); verify(mockRequestFactory, never()).cancelRun(); }
public static Request getClassesRequest(final String suiteName, Class[] classes, Map classMethods) { boolean canUseSuiteMethod = canUseSuiteMethod(classMethods); try { final Runner suite; if (canUseSuiteMethod) { suite = new IdeaSuite(collectWrappedRunners(classes), suiteName); } else { final AllDefaultPossibilitiesBuilder builder = new AllDefaultPossibilitiesBuilder(canUseSuiteMethod); suite = new IdeaSuite(builder, classes, suiteName); } return Request.runner(suite); } catch (InitializationError e) { throw new RuntimeException(e); } }
@Test public void ignoredTestAreReportedAsSuppressedTests() throws Exception { TestSuiteModelSupplier mockModelSupplier = mock(TestSuiteModelSupplier.class); TestSuiteModel mockModel = mock(TestSuiteModel.class); CancellableRequestFactory mockRequestFactory = mock(CancellableRequestFactory.class); OutputStream mockXmlStream = mock(OutputStream.class); JUnit4TestXmlListener listener = new JUnit4TestXmlListener( mockModelSupplier, mockRequestFactory, fakeSignalHandlers, mockXmlStream, errPrintStream); Request request = Request.classWithoutSuiteMethod(TestWithIgnoredTestCase.class); Description suiteDescription = request.getRunner().getDescription(); Description testDescription = suiteDescription.getChildren().get(0); when(mockModelSupplier.get()).thenReturn(mockModel); JUnitCore core = new JUnitCore(); core.addListener(listener); core.run(request); assertWithMessage("no output to stderr expected").that(errStream.size()).isEqualTo(0); InOrder inOrder = inOrder(mockModel); inOrder.verify(mockModel).testSuppressed(testDescription); inOrder.verify(mockModel).writeAsXml(mockXmlStream); verify(mockRequestFactory, never()).cancelRun(); }
@Test public void testCancelRunBeforeStarting() throws Exception { final AtomicBoolean testRan = new AtomicBoolean(false); // A runner that should never run its test FakeRunner runner = new FakeRunner("shouldNotRun", new Runnable() { @Override public void run() { testRan.set(true); } }); Request request = cancellableRequestFactory.createRequest(Request.runner(runner)); cancellableRequestFactory.cancelRun(); JUnitCore core = new JUnitCore(); try { core.run(request); fail("exception expected"); } catch (RuntimeException e) { assertThat(e).hasMessageThat().isEqualTo("Test run interrupted"); assertThat(e).hasCauseThat().isInstanceOf(StoppedByUserException.class); } assertThat(testRan.get()).isFalse(); }
@Test public void testNormalRun() { final AtomicBoolean testRan = new AtomicBoolean(false); // A runner that should run its test FakeRunner runner = new FakeRunner("shouldRun", new Runnable() { @Override public void run() { testRan.set(true); } }); Request request = cancellableRequestFactory.createRequest(Request.runner(runner)); JUnitCore core = new JUnitCore(); Result result = core.run(request); assertThat(testRan.get()).isTrue(); assertThat(result.getRunCount()).isEqualTo(1); assertThat(result.getFailureCount()).isEqualTo(0); }
List<Description> getAllDescriptions(Description description, String className) { final AllExceptIgnoredTestRunnerBuilder allExceptIgnoredTestRunnerBuilder = new AllExceptIgnoredTestRunnerBuilder(); try { final Class<?> testClass = description.getClass().getClassLoader().loadClass(className); Runner runner = allExceptIgnoredTestRunnerBuilder.runnerForClass(testClass); if (runner == null) { //fall back to default runner runner = Request.aClass(testClass).getRunner(); } final Description runnerDescription = runner.getDescription(); return runnerDescription.getChildren(); } catch (Throwable throwable) { throw new TestSuiteExecutionException(String.format("Unable to process Ignored class %s.", className), throwable); } }
@Test @DisplayName("Should set full name") public void shouldSetTestFullName() throws Exception { core.run(Request.aClass(OneTest.class)); List<TestResult> testResults = results.getTestResults(); assertThat(testResults) .hasSize(1) .extracting(TestResult::getFullName) .containsExactly("io.qameta.allure.junit4.samples.OneTest.simpleTest"); }
@Test @DisplayName("Should set start time") public void shouldSetTestStart() throws Exception { core.run(Request.aClass(OneTest.class)); List<TestResult> testResults = results.getTestResults(); assertThat(testResults) .hasSize(1) .extracting(TestResult::getStart) .isNotNull(); }
@Test @DisplayName("Should set stop time") public void shouldSetTestStop() throws Exception { core.run(Request.aClass(OneTest.class)); List<TestResult> testResults = results.getTestResults(); assertThat(testResults) .hasSize(1) .extracting(TestResult::getStop) .isNotNull(); }
@Test @DisplayName("Should set finished stage") public void shouldSetStageFinished() throws Exception { core.run(Request.aClass(OneTest.class)); List<TestResult> testResults = results.getTestResults(); assertThat(testResults) .hasSize(1) .extracting(TestResult::getStage) .containsExactly(Stage.FINISHED); }
@Test @DisplayName("Failed test") public void shouldProcessFailedTest() throws Exception { core.run(Request.aClass(FailedTest.class)); List<TestResult> testResults = results.getTestResults(); assertThat(testResults) .hasSize(1) .extracting(TestResult::getStatus) .containsExactly(Status.FAILED); }
@Test @DisplayName("Broken test") public void shouldProcessBrokenTest() throws Exception { core.run(Request.aClass(BrokenTest.class)); List<TestResult> testResults = results.getTestResults(); assertThat(testResults) .hasSize(1) .extracting(TestResult::getStatus) .containsExactly(Status.BROKEN); }