TestNG results to database

974 views
Skip to first unread message

b.l.sri...@gmail.com

unread,
Jul 28, 2014, 3:05:35 AM7/28/14
to testng...@googlegroups.com
Is there any utility which allows me to parse testng-results.xml file and give me as objects to play with? I have multiple testng-results files and i need to process/collate the results into a database.

Thanks in advance,
Srinivas

Krishnan Mahadevan

unread,
Jul 28, 2014, 9:32:36 PM7/28/14
to testng...@googlegroups.com
As I replied on the other thread, you are better off in creating your own reporter [ by implementing IReporter interface ] and build this on your own. 

~ Krishnan

iSent. iPhone. iReget.iTypos!
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

djangofan

unread,
Jul 29, 2014, 11:24:43 AM7/29/14
to testng...@googlegroups.com
Yes, you can do that. After each method , push the results to a CouchDB.    Something like this:


         @AfterMethod
public void reportIt( ITestResult result )
{
                Object[]  testParams = result.getParameters();
                String testName = (String)testParams[1];
                boolean resultStatus = result.isSuccess();
pushResultToCouchDB( testName, resultStatus);

Todd Bradley

unread,
Jun 27, 2015, 1:17:58 PM6/27/15
to testng...@googlegroups.com
Is there anything new from the past year in this area? Like the OP, I also want to slice and dice a bunch of existing test results. In my case, I have test results and reports from dozens of Hudson test runs. I'm having a problem that some of my test cases intermittently fail. Hudson's built-in stuff will show the "age" of a test result, in the sense that if a test failed the past 6 times, it'll show the number 6. But if it failed 6 times in a row, then passed, then failed again, that number in the GUI is reset.

What I really want to do is load a bunch of existing results into a database or spreadsheet or something so that I can answer the question of which test methods have failed most often, then the 2nd most option, etc. Basically, I'm doing a Pareto analysis to tell me which of our test cases are least stable. Pushing the test results at runtime into CouchDB isn't an option, because I've got historical test results I want to use.

Any suggestions?


Thanks,
Todd.

Cédric Beust ♔

unread,
Jun 27, 2015, 2:49:42 PM6/27/15
to testng...@googlegroups.com

Hi Todd,

It seems to me this is outside TestNG’s scope. You get a testng-results file after each run, you could then save these results in a database and slice and dice them yourself…


-- 
Cédric


--

Todd Bradley

unread,
Jun 27, 2015, 3:10:23 PM6/27/15
to testng...@googlegroups.com
Sure, but I don't want to invent the wheel if I don't have to. And who would know better whether a tool already exists to discover trends in a set of result files than other TestNG users?

I'm guessing from your answer that you don't know of such a tool, which probably means there is no such thing. 

If anyone HAS written something to do this that they would share, please let me know.

Cheers,
Todd. 



---
Sent from Boxer | http://getboxer.com

Cédric Beust ♔

unread,
Jun 27, 2015, 3:36:15 PM6/27/15
to testng...@googlegroups.com
Oh of course, I didn't mean to discourage you from finding users with similar needs as yours, I was just pointing out that I think this functionality doesn't belong in TestNG.


-- 
Cédric

Nagesh

unread,
Jun 29, 2015, 6:36:54 PM6/29/15
to testng...@googlegroups.com
Hi Todd,

I was trying to solve this problem at the start of the year with Bamboo, but soon realized like you that I had to find a tool if I needed to do further analysis of our runs. The only tool I know that does what you require is Cuanto. It is backed by a MySQL DB which stores all your results which is effectively what you need to do some analysis and trending of your results. The tool isn't under active development, but is open source. The last stable version is 2.8, but doesn't support parallel execution of tests. In order to support parallel runs, download this snapshot version, which is what I use.

The only major limitations I've run into so far is that I can't get it to work with Jetty 9.2 which supports Java 8. I've had to resort to using Jetty 8 (Java 1.6) which is pretty old. So if anybody has solved the problem or managed to migrate Jetty 8 to Jetty 9.2, please let me know :). The other strange issue I've run into which has caused me to restart Cuanto every other day is Cuanto TestNG Listener which seems to hang when running tests in parallel. To get around this, I'm thinking of adding Jetty as a Windows Service on the machine and restarting the service every night (when no builds are in progress).

I had to use a combination of install guides to understand how it works and install it locally to test and in production.

Hope this helps!

-Nagesh

Todd Bradley

unread,
Jul 1, 2015, 11:23:17 PM7/1/15
to testng...@googlegroups.com
Thanks, Nagesh. I'm glad you solved your problem using this toolset, but it sounds like there are a lot of limitations and hoops to jump through to make it work.

Bogdan Livadariu

unread,
Jul 2, 2015, 10:27:35 AM7/2/15
to testng...@googlegroups.com
I have created a lib that de-serializes testng-results.xml into java POJO,
I haven't yet pushed the code to git, but if you want you can find the artifacts here :
http://search.maven.org/#search|ga|1|a%3A%22testng-reporting-handlebars%22

if you want you can generate HTML results using : http://search.maven.org/remotecontent?filepath=com/github/bogdanlivadariu/testng-reporting-handlebars/1.0.0/testng-reporting-handlebars-1.0.0-jar-with-dependencies.jar
usage: java -jar -DxmlPath="path to your xml dir" -DreportsOutputPath="path to where the html reports will be generated" testng-reporting-handlebars-1.0.0-jar-with-dependencies.jar
and a HTML report will be published.

if you want to play with deserialized objects, you can use the support from the : testng-reporting-handlebars-1.0.0 lib.
if you have a maven project, you can add the dependency, and all is left next to do is to have something like this:
       
        String xml = "absolute path to testng-results.xml file";
        JAXBContext cntx = JAXBContext.newInstance(TestngResultsModel.class);

        Unmarshaller unm = cntx.createUnmarshaller();

        TestngResultsModel ts = (TestngResultsModel) unm.unmarshal(new File(xml));
Reply all
Reply to author
Forward
0 new messages