allure-framework / allure1

Allure 1 isn't supported any more, please consider using Allure 2 https://github.com/allure-framework/allure2 instead
Apache License 2.0
713 stars 169 forks source link

@Step is not displayed in report .xml mostly for all Listeners methods and for @Before, @After annotations #437

Closed tlytvyn closed 9 years ago

tlytvyn commented 9 years ago

I have such code:

@Step("After method step:") @AfterMethod public void tearDownTestBaseMethod(Method method) { LOG.info("Post Condition TEAR DOWN for method: " + method.getName()); TestLogHelper.stopTestLoggingSeparateMethod(); TestListenerUtil.attachLogToReporter(System.getProperty("logTestFolder"), method.getName()); }

where attachLogToReporter is marked with @Attachment(value = "Test log during execution for \"{1}\"", type="text/plain")

After test execution attachment is created in report folder near xml file but I can't see step in generated xml and in maven report as a result.

I also tried to extend TestListenerAdapter

and overrided there a method @Step("Test ended") @Override public void onFinish(ITestContext testContext) { TestListenerUtil.attachLogToReporter(System.getProperty("logTestFolder"), "demoTest"); }

result is the same.

But if we mark such methods with @step annotation like: onTestFailure(ITestResult result), onTestPass(ITestResult result), etc

we can see steps in report.

How to fix that or is there any wariant to handle that ability ???

Thank you

vania-pooh commented 9 years ago

@tlytvyn are your AspectJ settings correct?

braimanm commented 9 years ago

In current implementation of TestNG adapter we are showing only failed TestNG configuration methods in the report. Method annotated with @AfterMethod is considered as configuration method. Anyway you should not annotate any of TestNG annotated methods with Allure's @Step annotation as they will be shown as Test Case in the Allure report not as the Step.

vania-pooh commented 9 years ago

@braimanm thank you for clarification. TestNG for us is like a barrel with gunpowder. Nobody knows when and where it explodes.

tlytvyn commented 9 years ago

@vania-pooh I am using the next settings - attachments are working for me but as I mentioned above only, but not in other listeners methods like (public void onFinish(ITestContext testContext)) or in Before and After methods for testng annotations

- javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar
tlytvyn commented 9 years ago

@braimanm Yes, I understand that, but what about other listeners like (public void onFinish(ITestContext testContext)) ??

braimanm commented 9 years ago

onFinish event is triggered once at the end of suite execution. Tell me what you would like to achieve and I might help you.

tlytvyn commented 9 years ago

@braimanm I would like to attach all test log file to reporter, so whether I am attaching here onTestFailure(ITestResult result), onTestPass(ITestResult result), etc - that file doesn't include log text that was logged in @After annotations. But wheher I will be able to attach it on test finish - it will include. onFinish is called on test finished - not suite, I take it from TestListenerAdapter.

braimanm commented 9 years ago

Usually you don’t include Before and After methods in your report as they are not part of your test itself rather they are part of the test configuration. The only rational reason to show the configuration method in report is when they are failing. But if you would like to hook your code to configuration methods you should use methods of IConfigurationListener interface which are: onConfigurationSuccess , onConfigurationFailure and onConfigurationSkip.

tlytvyn commented 9 years ago

@braimanm so that IConfigurationListener listener methods could be annotated as steps with attachments ?

braimanm commented 9 years ago

You can extend AllureTestListener class and override IConfigurationListener methods.

baev commented 9 years ago

Seems like you solve the problem. You can reopen if needed