I am currently looking into the ability to upload testng reports to Amazon S3 after test suite execution, based on parameters in the testng xml. Consider the following testng xml:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Base Framework Unit Test Suite" verbose="1" >
<parameter name="upload-test-reports" value="true" />
<parameter name="aws-provider-type" value="profile" />
<parameter name="aws-s3-bucket" value="qa-reports" />
<parameter name="target-reports-directory" value="TestProduct/Sprint1" />
<test name="Test-base-built Unit Tests" >
<parameter name="test-run-type" value="local" />
<parameter name="name" value="Test-base-built Unit Tests" />
<parameter name="browser" value="htmlunitwithjs" />
<groups>
<run>
<include name="unittest" />
</run>
</groups>
<classes>
<class name="unittest.TestBaseBuilt_Test" />
</classes>
</test>
</suite>
Given the first four parameters (upload-test-reports, aws-provider-type, aws-s3-bucket, and target-reports-directory), the Java project will upload all files in the default test output directory (which is currently /build/reports/tests) to S3.
Now, the upload part is working fine for me. The problem is that it always uploads the files from the previous test run. I have tried creating a testng listener extending TestListenerAdapter and putting the upload logic in the onFinish method. That didn't work; it uploaded before the current run's reports generated. I also tried to write a custom testng reporter implementing IReporter and putting the upload logic in the generateReport method. Same result; it uploaded before the current run's reports generated.
So, do any testng experts out there know where I can put my file upload logic so that it executes AFTER testng actually generates the report files?
Any help is much appreciated!