ru.yandex.qatools.allure.Allure Java Examples

The following examples show how to use ru.yandex.qatools.allure.Allure. 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: AllureMarathonRunListener.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public AllureMarathonRunListener() {
    Field config;
    try {
        config = AllureResultsUtils.class.getDeclaredField("CONFIG");
        Field modifiersField = Field.class.getDeclaredField("modifiers");
        modifiersField.setAccessible(true);
        modifiersField.setInt(config, config.getModifiers() & ~Modifier.FINAL);
        config.setAccessible(true);
        config.set(null, AllureConfig.newInstance());
        AllureResultsUtils.setResultsDirectory(null);
        Constructor<Allure> constructor = Allure.class.getDeclaredConstructor();
        constructor.setAccessible(true);
        lifecycle = constructor.newInstance();
        issues = Group.getGroups(GroupType.ISSUE);
        features = Group.getGroups(GroupType.FEATURE);
        stories = Group.getGroups(GroupType.STORY);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #2
Source File: AllureTestListenerTest.java    From allure1 with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
    testngListener = spy(new AllureTestListener());
    allure = mock(Allure.class);

    testngListener.setLifecycle(allure);

    ISuite suite = mock(ISuite.class);
    when(suite.getName()).thenReturn(DEFAULT_SUITE_NAME);
    XmlTest xmlTest = mock(XmlTest.class);
    when(xmlTest.getName()).thenReturn(DEFAULT_XML_TEST_NAME);
    testContext = mock(ITestContext.class);
    when(testContext.getSuite()).thenReturn(suite);
    when(testContext.getCurrentXmlTest()).thenReturn(xmlTest);

    // mocking test method parameters
    ConstructorOrMethod constructorOrMethod = mock(ConstructorOrMethod.class);
    when(constructorOrMethod.getMethod()).thenReturn(parametrizedTestMethod(0, null, null, null));
    method = mock(ITestNGMethod.class);
    when(method.getConstructorOrMethod()).thenReturn(constructorOrMethod);
    testResult = mock(ITestResult.class);
    when(testResult.getMethod()).thenReturn(method);
    when(testResult.getParameters()).thenReturn(new Object[]{});
    IClass iClass = mock(IClass.class);
    when(testResult.getTestClass()).thenReturn(iClass);
}
 
Example #3
Source File: AllureParametersAspects.java    From allure1 with Apache License 2.0 5 votes vote down vote up
@After("setValueToAnyField() && withParameterAnnotation()")
public void parameterValueChanged(JoinPoint joinPoint) {
    try {
        FieldSignature fieldSignature = (FieldSignature) joinPoint.getSignature();
        Parameter parameter = fieldSignature.getField().getAnnotation(Parameter.class);
        String name = parameter.value().isEmpty() ? fieldSignature.getName() : parameter.value();
        Allure.LIFECYCLE.fire(new AddParameterEvent(name, joinPoint.getArgs()[0].toString()));
    } catch (Exception ignored) {
    }
}
 
Example #4
Source File: AllureShutdownHook.java    From allure1 with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #5
Source File: TestWithTimeoutRule.java    From allure1 with Apache License 2.0 5 votes vote down vote up
@Test
public void someTest() throws Exception {
    Allure.LIFECYCLE.fire(new TestCaseEvent() {
        @Override
        public void process(TestCaseResult context) {
            context.setTitle(TestWithTimeoutAnnotation.NAME);
        }
    });
}
 
Example #6
Source File: AllureRunListenerTest.java    From allure1 with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    runListener = spy(new AllureRunListener());

    allure = mock(Allure.class);
    runListener.setLifecycle(allure);
}
 
Example #7
Source File: TestWithTimeoutAnnotation.java    From allure1 with Apache License 2.0 5 votes vote down vote up
@Test(timeout = 10000)
public void someTest() throws Exception {
    Allure.LIFECYCLE.fire(new TestCaseEvent() {
        @Override
        public void process(TestCaseResult context) {
            context.setTitle(NAME);
        }
    });
}
 
Example #8
Source File: AllureRunListener.java    From allure1 with Apache License 2.0 4 votes vote down vote up
public void setLifecycle(Allure lifecycle) {
    this.lifecycle = lifecycle;
}
 
Example #9
Source File: AllureStepsAspects.java    From allure1 with Apache License 2.0 4 votes vote down vote up
/**
 * For tests only
 */
static void setAllure(Allure allure) {
    AllureStepsAspects.ALLURE = allure;
}
 
Example #10
Source File: AllureAttachAspects.java    From allure1 with Apache License 2.0 4 votes vote down vote up
/**
 * For tests only
 */
static void setAllure(Allure allure) {
    AllureAttachAspects.ALLURE = allure;
}
 
Example #11
Source File: AllureTestListener.java    From allure1 with Apache License 2.0 4 votes vote down vote up
void setLifecycle(Allure lifecycle) {
    this.lifecycle = lifecycle;
}
 
Example #12
Source File: AllureTestListener.java    From allure1 with Apache License 2.0 4 votes vote down vote up
Allure getLifecycle() {
    return lifecycle;
}
 
Example #13
Source File: AllureReporter.java    From colibri-ui with Apache License 2.0 4 votes vote down vote up
public void takeScreenshot(String step) {
    if (applicationContext.getBean(AppiumDriver.class) != null) {
        Allure.LIFECYCLE.fire(new MakeAttachmentEvent((applicationContext.getBean(AppiumDriver.class)).getScreenshotAs(OutputType.BYTES), step, "image/png"));
    }
}
 
Example #14
Source File: AllureRunListener.java    From allure1 with Apache License 2.0 4 votes vote down vote up
public Allure getLifecycle() {
    return lifecycle;
}
 
Example #15
Source File: AllureRunListener.java    From allure-cucumberjvm with Apache License 2.0 4 votes vote down vote up
public void setLifecycle(Allure lifecycle) {
    this.lifecycle = lifecycle;
}
 
Example #16
Source File: AllureRunListener.java    From allure-cucumberjvm with Apache License 2.0 4 votes vote down vote up
public Allure getLifecycle() {
    return lifecycle;
}
 
Example #17
Source File: AllureMarathonRunListener.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public void setLifecycle(Allure lifecycle) {
    this.lifecycle = lifecycle;
}
 
Example #18
Source File: AllureMarathonRunListener.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public Allure getLifecycle() {
    return lifecycle;
}
 
Example #19
Source File: ScreenShotEntry.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public void fire(Allure lifecycle) {
    MakeAttachmentEvent event = makeAttachmentEvent();
    if (event != null)
        lifecycle.fire(event);
}