ru.yandex.qatools.allure.model.TestCaseResult Java Examples
The following examples show how to use
ru.yandex.qatools.allure.model.TestCaseResult.
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: AllureTestListenerConfigMethodsTest.java From allure1 with Apache License 2.0 | 6 votes |
private void validateTestSuiteResult(TestSuiteResult testSuiteResult) { String brokenMethod = testSuiteResult.getName().replace(SUITE_PREFIX, "config"); for (TestCaseResult result : testSuiteResult.getTestCases()) { String methodName = result.getName(); Status status = result.getStatus(); Status expectedStatus = Status.CANCELED; if (brokenMethod.startsWith(methodName)) { expectedStatus = Status.BROKEN; } if (brokenMethod.contains("After") && methodName.equalsIgnoreCase("test")) { expectedStatus = Status.PASSED; } assertThat(String.format("Wrong status for test <%s>, method <%s>", brokenMethod, methodName), status, equalTo(expectedStatus)); } }
Example #2
Source File: TestCaseReader.java From allure1 with Apache License 2.0 | 6 votes |
@Override public TestCaseResult next() { if (!hasNext()) { return null; } TestCaseResult result = testCases.next(); Set<Label> labels = new HashSet<>(currentSuite.getLabels()); labels.add(new Label().withName(SUITE_NAME).withValue(currentSuite.getName())); labels.add(new Label().withName(SUITE_TITLE).withValue(currentSuite.getTitle())); labels.addAll(result.getLabels()); result.setLabels(new ArrayList<>(labels)); Description description = mergeDescriptions(currentSuite, result); result.setDescription(description); return result; }
Example #3
Source File: AllureGuiceModule.java From allure1 with Apache License 2.0 | 6 votes |
@Override protected void configure() { bind(File[].class).annotatedWith(ResultDirectories.class).toInstance(inputDirectories); bind(ClassLoader.class).annotatedWith(PluginClassLoader.class).toInstance(classLoader); bind(new TypeLiteral<Reader<TestSuiteResult>>() { }).to(TestSuiteReader.class); bind(new TypeLiteral<Reader<TestCaseResult>>() { }).to(TestCaseReader.class); bind(new TypeLiteral<Reader<Environment>>() { }).to(EnvironmentReader.class); bind(new TypeLiteral<Reader<AttachmentInfo>>() { }).to(AttachmentReader.class); bind(PluginLoader.class).to(DefaultPluginLoader.class); bind(AttachmentsIndex.class).to(DefaultAttachmentsIndex.class); bind(TestCaseConverter.class).to(DefaultTestCaseConverter.class); }
Example #4
Source File: AllureLifecycleTest.java From allure1 with Apache License 2.0 | 6 votes |
@Test public void allureClearStorageTest() { String suiteUid = UUID.randomUUID().toString(); TestSuiteResult testSuite = fireTestSuiteStart(suiteUid); TestCaseResult testCase = fireTestCaseStart(suiteUid); assertThat(testSuite.getTestCases(), hasSize(1)); assertEquals(testSuite.getTestCases().get(0), testCase); Step parentStep = fireStepStart(); Step nestedStep = fireStepStart(); fireStepFinished(); assertThat(parentStep.getSteps(), hasSize(1)); assertTrue(parentStep.getSteps().get(0) == nestedStep); fireStepFinished(); fireClearStepStorage(); assertThat(testCase.getSteps(), hasSize(0)); fireClearTestStorage(); TestCaseResult afterClearing = Allure.LIFECYCLE.getTestCaseStorage().get(); assertFalse(testCase == afterClearing); checkTestCaseIsNew(afterClearing); }
Example #5
Source File: Allure.java From allure1 with Apache License 2.0 | 6 votes |
/** * Process TestCaseFinishedEvent. Add steps and attachments from * top step from stepStorage to current testCase, then remove testCase * and step from stores. Also remove attachments matches removeAttachments * config. * * @param event to process */ public void fire(TestCaseFinishedEvent event) { TestCaseResult testCase = testCaseStorage.get(); event.process(testCase); Step root = stepStorage.pollLast(); if (Status.PASSED.equals(testCase.getStatus())) { new RemoveAttachmentsEvent(AllureConfig.newInstance().getRemoveAttachments()).process(root); } testCase.getSteps().addAll(root.getSteps()); testCase.getAttachments().addAll(root.getAttachments()); stepStorage.remove(); testCaseStorage.remove(); notifier.fire(event); }
Example #6
Source File: AllureReportGenerator.java From AuTe-Framework with Apache License 2.0 | 5 votes |
private TestCaseResult buildTestCaseData(File resultDirectory, Scenario scenario, List<StepResult> stepResults) { List<Step> steps = buildStepsData(resultDirectory, stepResults); return new TestCaseResult() .withName(scenario.getName()) .withStart(steps.stream().mapToLong(Step::getStart).min().orElse(0)) .withStop(steps.stream().mapToLong(Step::getStop).max().orElse(0)) .withStatus(steps.stream().anyMatch(step -> FAILED.equals(step.getStatus())) ? FAILED : PASSED) .withSteps(steps); }
Example #7
Source File: AllureTestListenerMultipleSuitesTest.java From allure1 with Apache License 2.0 | 5 votes |
@Test public void validatePendingTest() throws IOException { TestSuiteResult testSuite = AllureFileUtils.unmarshalSuites(resultsDir.toFile()).get(0); TestCaseResult testResult = testSuite.getTestCases().get(0); assertThat(testResult.getStatus(), equalTo(Status.PENDING)); assertThat(testResult.getDescription().getValue(), equalTo("This is pending test")); }
Example #8
Source File: TestWithTimeoutRule.java From allure1 with Apache License 2.0 | 5 votes |
@Test public void someTest() throws Exception { Allure.LIFECYCLE.fire(new TestCaseEvent() { @Override public void process(TestCaseResult context) { context.setTitle(TestWithTimeoutAnnotation.NAME); } }); }
Example #9
Source File: TestWithTimeoutAnnotation.java From allure1 with Apache License 2.0 | 5 votes |
@Test(timeout = 10000) public void someTest() throws Exception { Allure.LIFECYCLE.fire(new TestCaseEvent() { @Override public void process(TestCaseResult context) { context.setTitle(NAME); } }); }
Example #10
Source File: AllureReportGenerator.java From allure1 with Apache License 2.0 | 5 votes |
public void generate(ReportWriter writer) { if (!testCaseReader.iterator().hasNext()) { throw new ReportGenerationException("Could not find any allure results"); } writer.writeIndexHtml(pluginManager.getPluginsNames()); for (TestCaseResult result : testCaseReader) { pluginManager.prepare(result); AllureTestCase testCase = converter.convert(result); pluginManager.prepare(testCase); pluginManager.process(testCase); writer.write(testCase); } for (Environment environment : environmentReader) { pluginManager.prepare(environment); pluginManager.process(environment); } for (AttachmentInfo attachment : attachmentReader) { pluginManager.prepare(attachment); writer.write(attachment); } pluginManager.writePluginData(writer); pluginManager.writePluginResources(writer); pluginManager.writePluginList(writer); pluginManager.writePluginWidgets(writer); writer.writeReportInfo(); }
Example #11
Source File: ListenersNotifierTest.java From allure1 with Apache License 2.0 | 5 votes |
@Test public void testcaseEventTest() throws Exception { allure.fire(new TestCaseEvent() { @Override public void process(TestCaseResult context) { } }); assertThat(listener.get(SimpleListener.EventType.TESTCASE_EVENT), is(1)); }
Example #12
Source File: AllureLifecycleTest.java From allure1 with Apache License 2.0 | 5 votes |
public TestCaseResult fireCustomTestCaseEvent() { Allure.LIFECYCLE.fire(new ChangeTestCaseTitleEvent("new.case.title")); TestCaseResult testCase = Allure.LIFECYCLE.getTestCaseStorage().get(); assertNotNull(testCase); assertThat(testCase.getTitle(), is("new.case.title")); return testCase; }
Example #13
Source File: AllureLifecycleTest.java From allure1 with Apache License 2.0 | 5 votes |
public TestCaseResult fireTestCaseStart(String uid) { Allure.LIFECYCLE.fire(new TestCaseStartedEvent(uid, "some.case.name")); TestCaseResult testCase = Allure.LIFECYCLE.getTestCaseStorage().get(); assertNotNull(testCase); assertThat(testCase.getName(), is("some.case.name")); return testCase; }
Example #14
Source File: AllureLifecycleTest.java From allure1 with Apache License 2.0 | 5 votes |
private void checkTestCaseIsNew(TestCaseResult testCaseResult) { assertNull(testCaseResult.getName()); assertNull(testCaseResult.getTitle()); assertNull(testCaseResult.getDescription()); assertNull(testCaseResult.getFailure()); assertNull(testCaseResult.getStatus()); assertTrue(testCaseResult.getSteps().isEmpty()); assertTrue(testCaseResult.getAttachments().isEmpty()); assertTrue(testCaseResult.getLabels().isEmpty()); assertTrue(testCaseResult.getParameters().isEmpty()); assertTrue(testCaseResult.getStart() == 0 && testCaseResult.getStop() == 0); }
Example #15
Source File: AllureReportGenerator.java From AuTe-Framework with Apache License 2.0 | 5 votes |
private List<TestCaseResult> buildTestCasesData( File resultDirectory, String group, Map<Scenario, List<StepResult>> scenarioStepResultMap ) { return scenarioStepResultMap.entrySet().stream() .filter(entry -> group.equals(entry.getKey().getScenarioGroup() == null ? WITHOUT_GROUP : entry.getKey().getScenarioGroup())) .map(entry -> buildTestCaseData(resultDirectory, entry.getKey(), entry.getValue())) .collect(Collectors.toList()); }
Example #16
Source File: Allure.java From allure1 with Apache License 2.0 | 5 votes |
/** * Process TestCaseEvent. You can change current testCase context * using this method. * * @param event to process */ public void fire(TestCaseEvent event) { TestCaseResult testCase = testCaseStorage.get(); event.process(testCase); notifier.fire(event); }
Example #17
Source File: Allure.java From allure1 with Apache License 2.0 | 5 votes |
/** * Process TestCaseStartedEvent. New testCase will be created and added * to suite as child. * * @param event to process */ public void fire(TestCaseStartedEvent event) { //init root step in parent thread if needed stepStorage.get(); TestCaseResult testCase = testCaseStorage.get(); event.process(testCase); synchronized (TEST_SUITE_ADD_CHILD_LOCK) { testSuiteStorage.get(event.getSuiteUid()).getTestCases().add(testCase); } notifier.fire(event); }
Example #18
Source File: AddParameterEvent.java From allure1 with Apache License 2.0 | 5 votes |
/** * Add parameter to testCase * * @param context which can be changed */ @Override public void process(TestCaseResult context) { context.getParameters().add(new Parameter() .withName(getName()) .withValue(getValue()) .withKind(ParameterKind.valueOf(getKind())) ); }
Example #19
Source File: Allure1Plugin.java From allure2 with Apache License 2.0 | 5 votes |
private List<Parameter> getParameters(final TestCaseResult source) { final TreeSet<Parameter> parametersSet = new TreeSet<>( comparing(Parameter::getName, nullsFirst(naturalOrder())) .thenComparing(Parameter::getValue, nullsFirst(naturalOrder())) ); parametersSet.addAll(convert(source.getParameters(), this::hasArgumentType, this::convert)); return new ArrayList<>(parametersSet); }
Example #20
Source File: AllureShutdownHook.java From allure1 with Apache License 2.0 | 5 votes |
/** * Mark unfinished test cases as interrupted for each unfinished test suite, then write * test suite result * @see #createFakeTestcaseWithWarning(ru.yandex.qatools.allure.model.TestSuiteResult) * @see #markTestcaseAsInterruptedIfNotFinishedYet(ru.yandex.qatools.allure.model.TestCaseResult) */ @Override public void run() { for (Map.Entry<String, TestSuiteResult> entry : testSuites) { for (TestCaseResult testCase : entry.getValue().getTestCases()) { markTestcaseAsInterruptedIfNotFinishedYet(testCase); } entry.getValue().getTestCases().add(createFakeTestcaseWithWarning(entry.getValue())); Allure.LIFECYCLE.fire(new TestSuiteFinishedEvent(entry.getKey())); } }
Example #21
Source File: AllureShutdownHook.java From allure1 with Apache License 2.0 | 5 votes |
/** * Create fake test case, which will used for mark suite as interrupted. */ public TestCaseResult createFakeTestcaseWithWarning(TestSuiteResult testSuite) { return new TestCaseResult() .withName(testSuite.getName()) .withTitle(testSuite.getName()) .withStart(testSuite.getStart()) .withStop(System.currentTimeMillis()) .withFailure(new Failure().withMessage("Test suite was interrupted, some test cases may be lost")) .withStatus(Status.BROKEN); }
Example #22
Source File: TestCaseStartedEvent.java From allure1 with Apache License 2.0 | 5 votes |
/** * Sets to testCase start time, default status, name, title, description and labels * * @param testCase to change */ @Override public void process(TestCaseResult testCase) { testCase.setStart(System.currentTimeMillis()); testCase.setStatus(Status.PASSED); testCase.setName(getName()); testCase.setTitle(getTitle()); testCase.setDescription(getDescription()); testCase.setLabels(getLabels()); }
Example #23
Source File: AllureShutdownHook.java From allure1 with Apache License 2.0 | 5 votes |
/** * If test not finished yet (in our case if stop time is zero) mark it as interrupted. * Set message, stop time and status. */ public void markTestcaseAsInterruptedIfNotFinishedYet(TestCaseResult testCase) { if (testCase.getStop() == 0L) { testCase.setStop(System.currentTimeMillis()); testCase.setStatus(Status.BROKEN); testCase.setFailure(new Failure().withMessage("Test was interrupted")); } }
Example #24
Source File: DescriptionUtils.java From allure1 with Apache License 2.0 | 4 votes |
public static Description mergeDescriptions(TestSuiteResult testSuiteResult, TestCaseResult testCaseResult) { return mergeDescriptions(testSuiteResult.getDescription(), testCaseResult.getDescription()); }
Example #25
Source File: Allure1Plugin.java From allure2 with Apache License 2.0 | 4 votes |
private List<ru.yandex.qatools.allure.model.Parameter> getEnvironmentParameters(final TestCaseResult testCase) { return testCase.getParameters().stream().filter(this::hasEnvType).collect(toList()); }
Example #26
Source File: TestCaseReader.java From allure1 with Apache License 2.0 | 4 votes |
@Override public Iterator<TestCaseResult> iterator() { return new TestCaseResultIterator(); }
Example #27
Source File: TestCaseStorageTest.java From allure1 with Apache License 2.0 | 4 votes |
@Test public void simpleTest() throws Exception { TestCaseStorage storage = new TestCaseStorage(); TestCaseResult testCase = storage.get(); assertTrue(testCase == storage.get()); }
Example #28
Source File: AllureLifecycleTest.java From allure1 with Apache License 2.0 | 4 votes |
@Test public void allureLifecycleTest() throws Exception { String uid = UUID.randomUUID().toString(); TestSuiteResult testSuite = fireTestSuiteStart(uid); TestSuiteResult anotherTestSuite = fireCustomTestSuiteEvent(uid); assertEquals(testSuite, anotherTestSuite); TestCaseResult testCase = fireTestCaseStart(uid); TestCaseResult anotherTestCase = fireCustomTestCaseEvent(); assertEquals(testCase, anotherTestCase); assertThat(testSuite.getTestCases(), hasSize(1)); assertEquals(testSuite.getTestCases().get(0), testCase); Step parentStep = fireStepStart(); Attachment firstAttach = fireMakeAttachment(); assertThat(parentStep.getAttachments(), hasSize(1)); assertEquals(parentStep.getAttachments().get(0), firstAttach); Step nestedStep = fireStepStart(); Attachment secondAttach = fireMakeAttachment(); assertFalse(firstAttach == secondAttach); assertThat(nestedStep.getAttachments(), hasSize(1)); assertTrue(nestedStep.getAttachments().get(0) == secondAttach); fireStepFinished(); assertThat(parentStep.getSteps(), hasSize(1)); assertEquals(parentStep.getSteps().get(0), nestedStep); fireStepFinished(); Attachment testCaseAttachment = fireMakeAttachment(); fireTestCaseFinished(); assertThat(testCase.getSteps(), hasSize(1)); assertEquals(testCase.getSteps().get(0), parentStep); assertThat(testCase.getAttachments(), hasSize(1)); assertEquals(testCase.getAttachments().get(0), testCaseAttachment); fireTestSuiteFinished(uid); validateTestSuite(); assertThat(testSuite.getTestCases(), hasSize(1)); String otherUid = UUID.randomUUID().toString(); TestSuiteResult nextTestSuite = fireTestSuiteStart(otherUid); assertNotEquals(anotherTestSuite, nextTestSuite); }
Example #29
Source File: ChangeTestCaseTitleEvent.java From allure1 with Apache License 2.0 | 4 votes |
@Override public void process(TestCaseResult context) { context.setTitle(title); }
Example #30
Source File: TestCaseStorage.java From allure1 with Apache License 2.0 | 2 votes |
/** * Returns the current thread's "initial value". Construct an new * {@link ru.yandex.qatools.allure.model.TestCaseResult} * * @return the initial value for this thread-local */ @Override protected TestCaseResult initialValue() { return new TestCaseResult(); }