Search in sources :

Example 1 with Citrus

use of com.consol.citrus.Citrus in project allure-java by allure-framework.

the class AllureCitrusTest method run.

@Step("Run test case {testDesigner}")
private AllureResults run(final TestDesigner testDesigner) {
    final AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(CitrusSpringConfig.class, AllureCitrusConfig.class);
    final Citrus citrus = Citrus.newInstance(applicationContext);
    final TestContext testContext = citrus.createTestContext();
    final TestActionListeners listeners = applicationContext.getBean(TestActionListeners.class);
    final AllureLifecycle defaultLifecycle = Allure.getLifecycle();
    final AllureLifecycle lifecycle = applicationContext.getBean(AllureLifecycle.class);
    try {
        Allure.setLifecycle(lifecycle);
        final TestCase testCase = testDesigner.getTestCase();
        testCase.setTestActionListeners(listeners);
        citrus.run(testCase, testContext);
    } catch (Exception ignored) {
    } finally {
        Allure.setLifecycle(defaultLifecycle);
    }
    return applicationContext.getBean(AllureResultsWriterStub.class);
}
Also used : Citrus(com.consol.citrus.Citrus) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) TestCase(com.consol.citrus.TestCase) TestContext(com.consol.citrus.context.TestContext) TestActionListeners(com.consol.citrus.report.TestActionListeners) AllureLifecycle(io.qameta.allure.AllureLifecycle) Step(io.qameta.allure.Step)

Aggregations

Citrus (com.consol.citrus.Citrus)1 TestCase (com.consol.citrus.TestCase)1 TestContext (com.consol.citrus.context.TestContext)1 TestActionListeners (com.consol.citrus.report.TestActionListeners)1 AllureLifecycle (io.qameta.allure.AllureLifecycle)1 Step (io.qameta.allure.Step)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1