-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Corrupted Cucumber.xml when using surefire.rerunFailingTestsCount parameter #2709
Comments
Do you have the full stacktrace for:
It should be in the dumpstream file. |
There is no dumpstream file in the /home/vsts/work/1/s/ui/target/surefire-reports/ folder, only the TEST-RunCucumberTest.xml file. |
I suppose you didn't configure your pipeline to capture it. Is the dump file also absent if you reproduce the problem locally? It would help a lot because it would provide the exact line that makes the mistake. |
Okay. I think I found it. You most likely have a scenario or feature without a name. For example: Feature:
Scenario:
Given a calculator I just turned on
When I add 4 and 7
Then the result is 2 As a work around you can give your scenarios and features a name. |
Nope. That's not actually it. Weird thing is, I can get a stack trace, but it's nothing like yours:
And I do need two failing scenarios in a feature to trigger the problem. Otherwise nothing bad happens at all. |
I'm not able to see any dump files, neither on Azure nor on the local machine. What I can say is that the issue is reproducing when having at least 2 failing tests (I use 4 tests, 2 which pass and 2 which fails) and the command My feature file looks like this:
When I check the TEST-RunCucumberTest.xml I saw, at the end of the file, the same error you've mentioned before:
The error is displayed when I run the maven command from terminal as well. The generated cucumber.xml is
Notice the testcase tag is not closed. When I run with the following command: mvn test -Dcucumber.filter.tags="@test" then the error is no longer displayed and the cucumber.xml report looks like this:
|
Cheers. Then I think I've got it. |
The JUnit Platform allows Scenarios and Examples to be selected by their unique id. This id is stable between test executions and can be used to rerun failing Scenarios and Examples. For practical reasons each unique id is processed individually[+] and results in a feature file being parsed. The parsed feature is then compiled into pickles. Both are mapped to a hierarchy of JUnit 5 test descriptors. These are then merged. The merge process will discard any duplicate nodes. Each time a feature file is parsed the parser will assign unique identifiers to all ast nodes and pickles. As a result the merged hierarchy of junit test descriptors contained pickles that belonged to a different feature file. This poses a problem for tools such as the junit-xml-formatter that depend on the identifiers in pickles and features to stitch everything back together. By caching the parsed feature files we ensure that within a single execution the internal identifiers do not change. + : It would actually matter little if we did process all unique ids at once, the problem would persist when uri selectors are used, either alone or in combination with unique id selectors. Fixes: #2709
The JUnit Platform allows Scenarios and Examples to be selected by their unique id. This id is stable between test executions and can be used to rerun failing Scenarios and Examples. For practical reasons each unique id is processed individually[+] and results in a feature file being parsed. The parsed feature is then compiled into pickles. Both are mapped to a hierarchy of JUnit 5 test descriptors. These are then merged. The merge process will discard any duplicate nodes. Each time a feature file is parsed the parser will assign unique identifiers to all ast nodes and pickles. As a result the merged hierarchy of junit test descriptors contained pickles that belonged to a different feature file. This poses a problem for tools such as the junit-xml-formatter that depend on the identifiers in pickles and features to stitch everything back together. By caching the parsed feature files we ensure that within a single execution the internal identifiers do not change. + : It would actually matter little if we did process all unique ids at once, the problem would persist when uri selectors are used, either alone or in combination with unique id selectors. Fixes: #2709
👓 What did you see?
Using Cucumber 7.11.0 or 7.11.1 and surefire.rerunFailingTestsCount parameter in order to run the UI tests pack, I noticed the report is no longer generated on Azure DevOps and the following warning message is displayed:
##[warning]Failed to read /home/vsts/work/1/s/ui/target/cucumber-xml-reports/cucumber.xml. Error : Unexpected end of file while parsing Name has occurred. Line 44, position 10..
✅ What did you expect to see?
With other version of Cucumber (tested with versions from 7.5 to 7.10), I saw the report generated like
📦 Which tool/library version are you using?
Cucumber 7.11.0/7.11.1, Selenium 4.8, Java 11, Maven compiler 3.10, Maven Surefire Plugin 3.0.0-M7, Azure DevOps
🔬 How could we reproduce it?
Steps to reproduce the behavior:
Install 'Cucumber' version '7.11.0 or 7.11.1', Java version 11, Selenium version 4.8, Maven compiler version 3.10, Maven Surefire Plugin version 3.0.0-M7
Have a feature file (with 4 scenarios, 2 of them need to fail in order to be rerun again and the cucumber report to be generated with the new results ) which run in an Azure DevOps pipeline, on a Docker machine, with the maven command: '-Dcucumber.filter.tags="@smoke" -Dsurefire.rerunFailingTestsCount=1' and test results file being created at '$(Build.SourcesDirectory)/ui/target/cucumber-xml-reports/cucumber.xml'
Run the pipeline and inspect the results
The build is green, even if there are failed tests. When looking at the results in the logs, I could see:
[WARNING] ForkStarter IOException: Element name cannot be empty
Element name cannot be empty. See the dump file /home/vsts/work/1/s/ui/target/surefire-reports/2023-03-20T06-39-40_033-jvmRun1.dumpstream
See warning
##[warning]Failed to read xxxxxx/ui/target/cucumber-xml-reports/cucumber.xml. Error : Unexpected end of file while parsing Name has occurred. Line 44, position 10..
This defect is reproducing on my local machine as well:
@suite
@IncludeEngines("cucumber")
@SelectDirectories("src/test/java/features")
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "steps")
@SuiteDisplayName("UI tests")
@IncludeTags("Test")
public class RunCucumberTest {
}
2. Run in maven terminal the command: mvn test -Dcucumber.filter.tags="@test" -Dsurefire.rerunFailingTestsCount=1
3. Open the cucumber.xml, the file contains only the first test which failed, and after the tag is closed, another tag for test case is not fully open, showing like this <testcase
📚 Any additional context?
From what I could see, this problem appears only when tests fail.
The content of the cucumber.xml file generated after running the tests on my local machine looks like this
The text was updated successfully, but these errors were encountered: