Skip to content

Commit

Permalink
Merge pull request #45 from melexis/Color-results-of-a-testcase
Browse files Browse the repository at this point in the history
Color the results of a testcase
  • Loading branch information
JasperCraeghs authored Jan 11, 2024
2 parents 0516048 + 8488495 commit 309f03c
Show file tree
Hide file tree
Showing 23 changed files with 329 additions and 80 deletions.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ recursive-include tests *.py
recursive-include tests *.rst
recursive-include tests *.xml
exclude tests/test_out/*

include doc/source/_static/xunit2rst.css
21 changes: 21 additions & 0 deletions doc/source/_static/xunit2rst.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.xunit2rst {
padding: 2px 5px;
letter-spacing: 1px;
white-space: nowrap;
border-radius: 3px;
}

.xunit2rst.skip {
color: black;
background-color: #fed84f;
}

.xunit2rst.pass {
color: black;
background-color: #97bd61;
}

.xunit2rst.fail {
color: white;
background-color: #ce3e01;
}
9 changes: 8 additions & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,14 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = [os.path.join(os.path.dirname(mlx.traceability.__file__), 'assets')]
html_static_path = [os.path.join(os.path.dirname(mlx.traceability.__file__), 'assets'),
'_static']

# These paths are either relative to html_static_path
# or fully qualified paths (eg. https://...)
html_css_files = [
'xunit2rst.css',
]

traceability_render_relationship_per_item = True

Expand Down
10 changes: 9 additions & 1 deletion mlx/xunit2rst.mako
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ def generate_body(input_string, indent, error_type=None):
wrapped = textwrap.fill(complete_string, width=(119 - len(indent)), break_on_hyphens=False, break_long_words=False)
return textwrap.indent(wrapped, indent)
%>\
.. role:: xunit2rst-skip
:class: xunit2rst skip
.. role:: xunit2rst-fail
:class: xunit2rst fail
.. role:: xunit2rst-pass
:class: xunit2rst pass

.. ${info.header_prefix}${report_name}:

${"=" * len(title)}
Expand Down Expand Up @@ -135,7 +142,8 @@ else:
:ext_robotframeworklog: ${log_file}:${"s1-" if indexes[0] else ""}s${indexes[0] if indexes[0] else 1}-t${indexes[1]}
% endif
Test result: ${test_result}
Test result: :xunit2rst-${test_result.lower()}:`${test_result}`
<% prepend_literal_block = True %>
% if failure_msg and relationship != 'passes':
% for test in tests:
Expand Down
16 changes: 13 additions & 3 deletions tests/test_in/itest_as_utest_report.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.. role:: xunit2rst-skip
:class: xunit2rst skip
.. role:: xunit2rst-fail
:class: xunit2rst fail
.. role:: xunit2rst-pass
:class: xunit2rst pass

.. _unit_test_report_itest_as_utest:

===================================
Expand All @@ -16,17 +23,20 @@ Test Reports
.. item:: REPORT_ITEST-FIRST_TEST Test report for ITEST-FIRST_TEST
:fails: ITEST-FIRST_TEST

Test result: Fail
Test result: :xunit2rst-fail:`Fail`


.. item:: REPORT_ITEST-AN_UNLINKED_TEST Test report for ITEST-AN_UNLINKED_TEST
:passes: ITEST-AN_UNLINKED_TEST

Test result: Pass
Test result: :xunit2rst-pass:`Pass`


.. item:: REPORT_ITEST-ANOTHER_TEST Test report for ITEST-ANOTHER_TEST
:passes: ITEST-ANOTHER_TEST

Test result: Pass
Test result: :xunit2rst-pass:`Pass`


Traceability Matrix
===================
Expand Down
16 changes: 13 additions & 3 deletions tests/test_in/itest_lin_report.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.. role:: xunit2rst-skip
:class: xunit2rst skip
.. role:: xunit2rst-fail
:class: xunit2rst fail
.. role:: xunit2rst-pass
:class: xunit2rst pass

.. _integration_test_report_itest_lin:

=====================================
Expand All @@ -16,17 +23,20 @@ Test Reports
.. item:: REPORT_ITEST_LIN-FIRST_TEST Test report for ITEST_LIN-FIRST_TEST
:fails: ITEST_LIN-FIRST_TEST

Test result: Fail
Test result: :xunit2rst-fail:`Fail`


.. item:: REPORT_ITEST_LIN-AN_UNLINKED_TEST Test report for ITEST_LIN-AN_UNLINKED_TEST
:passes: ITEST_LIN-AN_UNLINKED_TEST

Test result: Pass
Test result: :xunit2rst-pass:`Pass`


.. item:: REPORT_ITEST_LIN-ANOTHER_TEST Test report for ITEST_LIN-ANOTHER_TEST
:passes: ITEST_LIN-ANOTHER_TEST

Test result: Pass
Test result: :xunit2rst-pass:`Pass`


Traceability Matrix
===================
Expand Down
16 changes: 13 additions & 3 deletions tests/test_in/itest_lin_report_failures.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.. role:: xunit2rst-skip
:class: xunit2rst skip
.. role:: xunit2rst-fail
:class: xunit2rst fail
.. role:: xunit2rst-pass
:class: xunit2rst pass

.. _integration_test_report_itest_lin_report_failures:

=====================================================
Expand All @@ -16,7 +23,8 @@ Test Reports
.. item:: REPORT_ITEST-FIRST_TEST Test report for ITEST-FIRST_TEST
:fails: ITEST-FIRST_TEST

Test result: Fail
Test result: :xunit2rst-fail:`Fail`


::

Expand All @@ -27,12 +35,14 @@ Test Reports
.. item:: REPORT_ITEST-AN_UNLINKED_TEST Test report for ITEST-AN_UNLINKED_TEST
:passes: ITEST-AN_UNLINKED_TEST

Test result: Pass
Test result: :xunit2rst-pass:`Pass`


.. item:: REPORT_ITEST-ANOTHER_TEST Test report for ITEST-ANOTHER_TEST
:passes: ITEST-ANOTHER_TEST

Test result: Pass
Test result: :xunit2rst-pass:`Pass`


Traceability Matrix
===================
Expand Down
16 changes: 13 additions & 3 deletions tests/test_in/itest_report.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.. role:: xunit2rst-skip
:class: xunit2rst skip
.. role:: xunit2rst-fail
:class: xunit2rst fail
.. role:: xunit2rst-pass
:class: xunit2rst pass

.. _integration_test_report_itest:

=================================
Expand All @@ -16,17 +23,20 @@ Test Reports
.. item:: REPORT_ITEST-FIRST_TEST Test report for ITEST-FIRST_TEST
:fails: ITEST-FIRST_TEST

Test result: Fail
Test result: :xunit2rst-fail:`Fail`


.. item:: REPORT_ITEST-AN_UNLINKED_TEST Test report for ITEST-AN_UNLINKED_TEST
:passes: ITEST-AN_UNLINKED_TEST

Test result: Pass
Test result: :xunit2rst-pass:`Pass`


.. item:: REPORT_ITEST-ANOTHER_TEST Test report for ITEST-ANOTHER_TEST
:passes: ITEST-ANOTHER_TEST

Test result: Pass
Test result: :xunit2rst-pass:`Pass`


Traceability Matrix
===================
Expand Down
16 changes: 13 additions & 3 deletions tests/test_in/itest_report_extra_content.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.. role:: xunit2rst-skip
:class: xunit2rst skip
.. role:: xunit2rst-fail
:class: xunit2rst fail
.. role:: xunit2rst-pass
:class: xunit2rst pass

.. _integration_test_report_itest_report_extra_content:

======================================================
Expand All @@ -16,7 +23,8 @@ Test Reports
.. item:: REPORT_ITEST-FIRST_TEST Test report for ITEST-FIRST_TEST
:fails: ITEST-FIRST_TEST

Test result: Fail
Test result: :xunit2rst-fail:`Fail`


.. note::
This note is defined in ``doc/source/extra_content.yml`` and linked to ``doc/source/robot/example.robot`` in the ``Metadata`` section as shown in the snippet below:
Expand All @@ -29,12 +37,14 @@ Test Reports
.. item:: REPORT_ITEST-AN_UNLINKED_TEST Test report for ITEST-AN_UNLINKED_TEST
:passes: ITEST-AN_UNLINKED_TEST

Test result: Pass
Test result: :xunit2rst-pass:`Pass`


.. item:: REPORT_ITEST-ANOTHER_TEST Test report for ITEST-ANOTHER_TEST
:passes: ITEST-ANOTHER_TEST

Test result: Pass
Test result: :xunit2rst-pass:`Pass`


Extra content defined in `this YAML file`_, thanks to the feature :ref:`content`.

Expand Down
16 changes: 13 additions & 3 deletions tests/test_in/itest_report_log.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.. role:: xunit2rst-skip
:class: xunit2rst skip
.. role:: xunit2rst-fail
:class: xunit2rst fail
.. role:: xunit2rst-pass
:class: xunit2rst pass

.. _integration_test_report_itest_report_log:

============================================
Expand All @@ -17,17 +24,20 @@ Test Reports
.. item:: REPORT_ITEST-FIRST_TEST Test report for ITEST-FIRST_TEST
:fails: ITEST-FIRST_TEST

Test result: Fail
Test result: :xunit2rst-fail:`Fail`


.. item:: REPORT_ITEST-AN_UNLINKED_TEST Test report for ITEST-AN_UNLINKED_TEST
:passes: ITEST-AN_UNLINKED_TEST

Test result: Pass
Test result: :xunit2rst-pass:`Pass`


.. item:: REPORT_ITEST-ANOTHER_TEST Test report for ITEST-ANOTHER_TEST
:passes: ITEST-ANOTHER_TEST

Test result: Pass
Test result: :xunit2rst-pass:`Pass`


Traceability Matrix
===================
Expand Down
16 changes: 13 additions & 3 deletions tests/test_in/itest_report_log_links.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.. role:: xunit2rst-skip
:class: xunit2rst skip
.. role:: xunit2rst-fail
:class: xunit2rst fail
.. role:: xunit2rst-pass
:class: xunit2rst pass

.. _integration_test_report_itest_report_log_links:

==================================================
Expand All @@ -18,19 +25,22 @@ Test Reports
:fails: ITEST-FIRST_TEST
:ext_robotframeworklog: itest_log.html:s1-t1

Test result: Fail
Test result: :xunit2rst-fail:`Fail`


.. item:: REPORT_ITEST-AN_UNLINKED_TEST Test report for ITEST-AN_UNLINKED_TEST
:passes: ITEST-AN_UNLINKED_TEST
:ext_robotframeworklog: itest_log.html:s1-t2

Test result: Pass
Test result: :xunit2rst-pass:`Pass`


.. item:: REPORT_ITEST-ANOTHER_TEST Test report for ITEST-ANOTHER_TEST
:passes: ITEST-ANOTHER_TEST
:ext_robotframeworklog: itest_log.html:s1-t3

Test result: Pass
Test result: :xunit2rst-pass:`Pass`


Traceability Matrix
===================
Expand Down
Loading

0 comments on commit 309f03c

Please sign in to comment.