Question

Folks!

I'm new on TestNG, and I'm trying it with Maven (Surefire plugin) and Eclipse.

When my tests are run by Maven its reports are put on target/surefire-reports as expected, but the same tests when run by Eclipse TestNG plugin I'd like them to be put inside a target subfolder also (and as so be cleaned by clean Maven goal and ignored by git, not saying about respecting Maven folder organization), but always go to the default ${basedir}/test-output.

There is a way I can do it? I'd prefer one that I do not need to manually config Eclipse settings (Couldn't TestNG in detect it's a Maven project and so change its output folder consistently?), but if there is no such way, anyone surely will help.

TIA and regards,

Heleno

Was it helpful?

Solution

There is a no way that testng plugin can automatically figure out.

You can set your testng preferences at the workspace or project level. If you set it at the workbench level then for all projects, by default, testng would put the results there.

Go to Window->Prefs->TestNG.
Change Output directory to be same as maven output directory.

OTHER TIPS

You can follow the way that niharika_neo told... Elsewise you can also create timestamp enabled folder that would be created for every maven run you do, so won't let your testng reports bother you much. If still bothering put testng reports to a specific folder.

You can provide a different folder in your pom as --

<properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <timestamp>${maven.build.timestamp}</timestamp>
        <maven.build.timestamp.format>yyyyMMdd-HHmm</maven.build.timestamp.format>
    </properties>

and under configuration of your maven-surefire-plugin put --

<reportsDirectory>./test-output/${timestamp}</reportsDirectory>

You will need to reconfigure XML Reporter as described at http://testng.org/doc/documentation-main.html#logging-xml-reports to set the outputDirectory property.

From that page:

In order to configure this reporter you can use the -reporter option in the command line or the Ant task with the nested element. For each of these you must specify the class org.testng.reporters.XMLReporter. Please note that you cannot configure the built-in reporter because this one will only use default settings. If you need just the XML report with custom settings you will have to add it manually with one of the two methods and disable the default listeners.

It isn't clear how this translates into a configuration for the Maven Surefire plugin.

I had the same issue and I resolved it by going to Window-> Preferences -> TestNG From there I check marked Absolute output path and entered the absolute path in the Output directory. For example C:\TestResults

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top