Whenever I trigger my plan for running automated test cases using maven
It is showing build as success however the test cases executed is always 0
My framework is build using Cucumber, testng and maven
Hello Pramodh,
Welcome to Atlassian community
As I see you are using Maven, is your build producing test files. This should be in the xml format and should be present inside the build directory where Bamboo can read it, are you able to confirm if the xml files exist?
By default Maven will look into the default location, but you can modify it to look into a specific directory where the xml files are present
You can read more about it at https://confluence.atlassian.com/bamboo/configuring-a-test-task-289277052.html , there is also an option to use the test parser task to separately parse these test files if you which locations they are generated within the build directory.
Regards,
Shashank Kumar
**please don't forget to Accept the answer if your query was answered**
Hi Shashank,
When I run it is not showing reports at all, and also in the logs it is showing as 0 test runs
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.247 s - in TestSuite
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
this is what I meant 0 test cases running
Regards,
Reddy Pramodh A
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Pramodh,
This means your build is not producing any Test XML, which Bamboo will read to understand if it contains any test cases or if the XML is produced it is not in right format.
Can you check your code to validate if it produces valid test XML files which contains test cases which Bamboo can parse?
Can you see the location of these XML's in your build directory and make sure maven task is configured correctly to read those.
See one example repo which produces test cases like below which Bamboo can parse and show in the results.
The structure of the XML looks something like below
<UnitTest name="Storage_ReplaceAllAttributes_PathExist_1" storage="/data/active/alf/csharp/unittests/bin/x64/release/net48/unittests.dll" id="5ebe42c2-19b3-1d69-c76a-16997a3ce3c8">
<Execution id="0c097683-05f2-4220-aa5b-83014d724e29" />
<TestMethod codeBase="/data/Active/alf/csharp/UnitTests/bin/x64/Release/net48/UnitTests.dll" adapterTypeName="executor://mstestadapter/v2" className="UnitTests.StorageTests+SQLiteInMemoryStorageTests" name="Storage_ReplaceAllAttributes_PathExist_1" />
</UnitTest>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shashank,
When I'm running the maven command from the agent directly it is working fine without any issues able to run the test cases, however running from the bamboo plan it is not picking any test cases, I haven't changed any directory while running from agent. I'm running it from working directory where the code is checked out
Regards,
Reddy Pramodh A
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Pramodh,
Can you go to the build working directory and try to find out where are the test cases xml produced and paste the path here.
We'll be able to modify the maven task to look for the test case xml's in that directory.
Regards,
Shashank Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shashank,
We have below two paths
$bamboo.build.working.directory/src/test/resources/testng.xml
$bamboo.build.working.directory/target/test-classes/testng.xml
Regards,
Reddy Pramodh A
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Pramodh,
As per the above looks like the test classes are produced, so there can be either of below 2 problem
1. Bamboo is somehow not able to read the xml for test case counts
2. The XML is not in right format for Bamboo to understand the test case count.
For the first problem, let's try another way for Bamboo to Parse these test xml files
Can you try to use Junit test case parser task in your plan after the Maven build task and see if Bamboo is able to read these files, see below
In the logs you'll see the information that Bamboo is looking for these files in the directory mentioned.
simple 31-Jul-2023 10:43:29 Finished task 'Maven 3.x' with result: Success simple 31-Jul-2023 10:43:29 Starting task 'JUnit Parser' of type 'com.atlassian.bamboo.plugins.testresultparser:task.testresultparser.junit' simple 31-Jul-2023 10:43:29 Parsing test results under /var/atlassian/application-data/bamboo/local-working-dir/622593/SCRIP-TIC-JOB1...
There you'll see the message whether it is successful or not.
If Bamboo is able to parse the test results, but still the test case count is zero, it means that xml is not in right format for Bamboo to understand.
Please refer this page which provides one of the xml in correct format which Bamboo can read
https://confluence.atlassian.com/bamboo/junit-parsing-in-bamboo-289277357.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shashank,
we are using testng and so used testngparser. It is showing below error
simple 01-Aug-2023 08:20:26 Finished task 'Maven 3.x' with result: Success simple 01-Aug-2023 08:20:26 Starting task 'TestNG Parser' of type 'com.atlassian.bamboo.plugins.testresultparser:task.testresultparser.testng' simple 01-Aug-2023 08:20:26 Failing task since test cases were expected but none were found. simple 01-Aug-2023 08:20:26 Finished task 'TestNG Parser' with result: Failed
Regards,
Reddy Pramodh A
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Pramodh,
At this point It looks like Bamboo is reading the XML file, but not able to parse it, hence you are seeing the exception >
Failing task since test cases were expected but none were found.
Can you compare your XML file with the one provided in https://confluence.atlassian.com/bamboo/junit-parsing-in-bamboo-289277357.html and see if the format matches.
You can also looks for errors in the below files in the agent to see if there is any error thrown while processing the test file like missing tags etc ?
1. <bamboo-agent-home>logs>atlassian-bamboo.log
2. <bamboo-agent-home>atlassian-bamboo-agent.log
If you are still not able to understand the reason, I would suggest you to raise a ticket with Atlassian support with a valid SEN id, so that it can be looked further.
Regards,
Shashank Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.