Andrew Yochum
Andrew Yochum

Reputation: 95

Making TestNG Reporter output appear in Gradle HTML test reports

Most of my searching for this has come up dry, so I figured I'd just asked directly... Is it possible to get TestNG's Reporter output to appear in Gradle HTML reports?

To illustrate what I'm trying to do: I have a bunch of testNG test methods that call Reporter.log() to record some additional contextual information at runtime.

@Test
public void testCase() {
    Reporter.log("Something happened");
    Assert.assertTrue(true);
}

My Gradle task is setup as:

test {
    useTestNG() {
        suites("src/test/resources/testng.xml")
        useDefaultListeners = true
    }
}

Setting useDefaultListners = true was done intentionally so that testNG's XML result files would still be generated. I can see from the testng-results.xml that the Reporter log data is getting stored properly, but I can't seem to make it appear in Gradle's HTML report.

Per Mark Viera's suggestion on Gradle TestNG results output, I tried setting testLogging.showStandardStreams = true, but the Reporter logs still do not seem to get picked up.

I'm fairly new to Gradle and TestNG, so there may be something painfully obvious I'm missing here.

Any advice or nudge in the right direction would be appreciated.

Upvotes: 2

Views: 1767

Answers (1)

Andrew Yochum
Andrew Yochum

Reputation: 95

And I think I may have just (partially) answered my own question...

The trick was to use testLogging.showStandardStreams = true and to call the Reporter.log(String, boolean) overload that allows Reporter output to go to STDOUT. This allows the "Standard ouput" tab to appear under the test class information in the Gradle report (as was described by Mark Viera on Gradle TestNG results output).

Unfortunately, this is still not quite ideal for my needs. It would be nice to have the Reporter output appear with the test case that logged it. I'm still open to any advice on this.

Upvotes: 1

Related Questions