astj / flake8-formatter-junit-xml Goto Github PK
View Code? Open in Web Editor NEWJUnit XML formatter for flake8
License: MIT License
JUnit XML formatter for flake8
License: MIT License
Hello,
I'm using Jenkins plugin (Checkstyle) in order to publish the code style with using jenkins.
however, I'm getting the following error:
failed due to an exception: org.xml.sax.SAXException: Input stream is not a Checkstyle file.
Any idea what causes it?
Hi! I have trouble displaying resulting XML with Gitlab test reports feature. Currently, it only shows the source that generated the error and no information for exact place where the error has occurred.
As I understand Gitlab closely follows JUnit XML specification by IBM (or at least they bother to put a link to it from their documentation) and it does not specify file
and line
attributes for TestCase element. https://www.ibm.com/support/knowledgecenter/en/SSQ2R2_14.1.0/com.ibm.rsar.analysis.codereview.cobol.doc/topics/cac_useresults_junit.html
Could we have an option to write them as plain text output? Either to failure.message
or failure.text
would be great.
The output for success is invalid because it shows no tests have been run.
Here's an example from php-cs-fixer:
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="PHP CS Fixer" tests="1" assertions="1" failures="0" errors="0" time="1.392">
<testcase name="All OK" assertions="1"/>
</testsuite>
</testsuites>
Here's the output from this formatter:
<?xml version="1.0" ?>
<testsuites disabled="0" errors="0" failures="0" tests="0" time="0.0">
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/deploy/TrendingDeploy_py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/resources/__init___py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/controller/controller_py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/datasource/model/model_py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/deploy/adapter/aerospike_adapter_py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/controller/bestseller/best_seller_controller_py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/configs/global_config_py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/datasource/top_sku_category_brand_py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/deploy/adapter/__init___py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/migrations/alembic/env_py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/datasource/top_sku_category_py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/__init___py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/configs/trending/__init___py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/logs/__init___py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/connection/__init___py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/credential/__init___py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/migrations/alembic/versions/69d29ab22e1b_create_best_seller_table_py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/controller/most_viewed_controller_py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/datasource/__init___py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/controller/bestseller/best_seller_brand_controller_py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/controller/recently_viewed_controller_py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/datasource/top_sku_brand_py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/connection/redis_db_py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/controller/trending_controller_py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/controller/bestseller/best_seller_category_controller_py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/controller/bestseller/__init___py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/utils/read_files_py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/datasource/model/__init___py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/validation/__init___py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/controller/bestseller/best_seller_category_brand_controller_py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/utils/__init___py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/migrations/alembic/versions/4589f1620603_create_database_py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/deploy/best_seller_deploy_py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/controller/__init___py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/deploy/adapter/redis_adapter_py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/configs/best_seller/__init___py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/deploy/__init___py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/configs/most_viewed/__init___py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/deploy/MostViewedDeploy_py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/start_py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/connection/mysql_db_py" skipped="0" tests="0" time="0"/>
<testsuite disabled="0" errors="0" failures="0" name="flake8.src/configs/__init___py" skipped="0" tests="0" time="0"/>
</testsuites>
With 0 tests and 0 time Jenkins will not report that this is successful as no tests have been recorded.
GitLab CI requires every testcase to have a classname. I suggest using the Python module name of the file that was tested as classname attribute.
Would it be possible to add this attribute, so report frameworks can use it as key?
Thanks for this nice project!
What I report below is a minor issue, that surprised me (worked around now).
Running flake8 --format=junit-xml --output-file=flake8.xml
twice results in an invalid flake8.xml
file (second run's output appended to previous runs output):
$ mkdir empty-dir
$ flake8 --format=junit-xml --output=flake8.xml empty-dir/
$ flake8 --format=junit-xml --output=flake8.xml empty-dir/
$ head flake8.xml
<?xml version="1.0" ?>
<testsuites/>
<?xml version="1.0" ?>
<testsuites/>
It might be the behavior of flake8 --output-file
and not this plugin, however with junit-xml
it looked more natural to use the option --output-file
than shell-redirect output to file.
Is there any way with this plugin to output both to a file (using the formatter) and the screen using the default formatting? The --tee
option outputs to both file and screen however xml is written to the screen.
Please add support for python2:
Traceback (most recent call last):
File "/Users/harrison/.local/share/virtualenvs/recommendation-feeds-6IquZfue/bin/flake8", line 11, in <module>
sys.exit(main())
File "/Users/harrison/.local/share/virtualenvs/recommendation-feeds-6IquZfue/lib/python2.7/site-packages/flake8/main/cli.py", line 16, in main
app.run(argv)
File "/Users/harrison/.local/share/virtualenvs/recommendation-feeds-6IquZfue/lib/python2.7/site-packages/flake8/main/application.py", line 396, in run
self._run(argv)
File "/Users/harrison/.local/share/virtualenvs/recommendation-feeds-6IquZfue/lib/python2.7/site-packages/flake8/main/application.py", line 385, in _run
self.report()
File "/Users/harrison/.local/share/virtualenvs/recommendation-feeds-6IquZfue/lib/python2.7/site-packages/flake8/main/application.py", line 379, in report
self.formatter.stop()
File "/Users/harrison/.local/share/virtualenvs/recommendation-feeds-6IquZfue/lib/python2.7/site-packages/flake8_formatter_junit_xml/formatter.py", line 31, in stop
super().stop()
TypeError: super() takes at least 1 argument (0 given)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.