Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Show @Before- and @AfterMethod log in the test output #5

Open
ChaotX opened this Issue · 5 comments

3 participants

@ChaotX

Hi!

I'm wondering whether there is the possibility to include @BeforeMethod @AfterMethod reports to the test outputs.

It could be very useful to see these informations collected at each test (these are only appear in the full Log Output now).

@jostar

I'd be glad to have this functionality!
As things are now, i'm planing to drop the reportng and write my own report for exactly that reason...

@ChaotX
@jostar

If i remember correctly (from the last time i took a look at the Reporter from testNG), the only way to have the generated report to listen some foreign informations under a method is to use the setCurrentTestResult with a "faked" TestResult with the target method set. And that's what u r proposing, rigth? The problem is that the ITestResult has no read access on the method member. The class TestMethod has, but shouldn't be used from outside testNG (part of the "internal"-package with no guarantee of future stability).
I don't feel completely comfortable about deploying some code that possibly breaks in a future update of testNG in our company-wide test-framework.

B.t.w, how do u catch your setup exception? Is the TestListenerAdapter.onTestFailure() really reached if a problem allready happens in the setup?

Thx in advance,
Arno

@kielni

I would really like to be able to include the results of the AfterMethod too, since that's where I generate a screenshot for failed tests. This log output is included in the default testng reporter log, and I can't figure out why there but not in reportng.

I wrote a console logging listener that writes to stdout. It looks like the listeners get called before the after method:

[testng] 2012.08.09 16:48:55 testReporter onTestStart
[testng] [Invoker 1469937134] Invoking test.ReporterTest.testReporter
[testng] 2012.08.09 16:48:55 testReporter onTestSuccess (1 passed / 0 failed)
[testng] [Invoker 1469937134] Invoking @AfterMethod com.liveworld.selenium.ReporterTest.afterMethod()

How can I get the listener called later? How does the builtin testng reporter do it?

@kielni

I figured out how to do it by by putting the driver into the test context, extending ReportNG's HTMLReporter to implement onTestFailure and take the screenshot, and specifying a different utils class that adds the screenshot to the report output

details here: https://groups.google.com/forum/#!topic/testng-users/80g-iNKxR8g

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.