Skip to content
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

Test output as JUnit.xml. #26

Open
QGhd opened this issue Jul 28, 2023 · 5 comments
Open

Test output as JUnit.xml. #26

QGhd opened this issue Jul 28, 2023 · 5 comments

Comments

@QGhd
Copy link

QGhd commented Jul 28, 2023

Dear Sebastian (@awvwgk),

I use your nice and neat FORTRAN test driver. Thank you for sharing it!

To integrate the FORTRAN tests into an Azure DevOps build pipeline (means: let the test results being displayed properly), I have added a functionality to write the test results to a JUnit.xml file that can be consumed by Azure DevOps.
I referred to this xml schema: https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd. (This might be an alternative: https://github.com/junit-team/junit5/blob/22a64e7aad5ae0e3c9cf2a692f77bd3de8d1bbed/platform-tests/src/test/resources/jenkins-junit.xsd, but I have not used it.)

Are you interested to get my changes resp. to integrate them into your project?
If yes, how should I submit my code to you?

Kind regards,

Oliver

@awvwgk
Copy link
Member

awvwgk commented Jul 28, 2023

Thanks for your interest in this project. Contributions are welcome here, if you have an implementation or the plan to implement it yourself.

Given the way test-drive collects and runs tests I can imagine that a different routine for collecting tests would already be sufficient.

@QGhd
Copy link
Author

QGhd commented Jul 31, 2023

I have attached two changed source files (replacing src/testdrive.f90 and test/main.f90) as well as the resulting JUnit.xml file that is written along with the screen output. This xml is doing the job for us in an Azure DevOps pipeline based on the data that is also written on the screen.
The main.f90 uses 4 additional external subroutines from testdrive.f90. Two to open and close the Junit.xml and two to open and close the xml tag. The rest of the xml output is covered internally in testdrive.f90.
However, I assume that you would prefer to avoid these additional functions, but I choose a simple approach with minimal code changes, instead of a major rework of the module structure.

In addition, the JUnit.xml file references to an xml schema (JUnit.xsd from https://github.com/windyroad/JUnit-Schema). In theory the JUnit.xml should be conform to this schema, but it is not for several reasons:

  1. There are missing (required) xml tag attributes, like number of all/failed/succeeded/skipped tests per testsuite that are as summarized data not available at the time, when the according opening xml tag is written.
  2. There are missing xml tag attributes, like execution time, that are not stored in the code (as far as I could see).
  3. There is no corresponding xml tag in the schema file for the additional stdout/stderr output per testcase. Therefore, I added according xml tags () per testcase that are - following the xsd - only allowed once per testsuite.
    Fortunately, Azure DevOps does not care about the discrepancy, so we are fine with this setup (but it is not a generic solution).

I have also attached another xml schema file (jenkins-junit.xsd from https://github.com/junit-team/junit5 resp. https://junit.org/junit5/). To be honest I am not sure, what should be regarded as the standard for a JUnit.xml. In fact, I do not care much, since Azure DevOps test pipeline works fine. Others, however, may have a more specific opinion on the subject.

Let me know, if you want to discuss my changes or whether I can support you.
Thank you for considering my changes.

JUnit.zip

@awvwgk
Copy link
Member

awvwgk commented Jul 31, 2023

I think it is easier to open a pull request or post a patch here.

@QGhd
Copy link
Author

QGhd commented Jul 31, 2023

Will do.

@QGhd
Copy link
Author

QGhd commented Jul 31, 2023

Done: #27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants