@@ -877,6 +877,11 @@ def test_unity_test_case_runner(unity_tester):
877877 assert junit_report [3 ].find ('failure' ) is None
878878
879879
880+ def test_unity_test_case_runner_new (unity_tester ):
881+ unity_tester .run_all_cases ()
882+
883+
884+
880885def test_erase_all_with_port_cache (testdir ):
881886 testdir .makepyfile (r"""
882887 def test_erase_all_with_port_cache_case1(dut):
@@ -897,3 +902,93 @@ def test_erase_all_with_port_cache_case2(dut):
897902 )
898903
899904 result .assert_outcomes (passed = 2 )
905+
906+
907+ def test_no_preserve_python_tests (testdir ):
908+ testdir .makepyfile (r"""
909+ def test_python_case(dut):
910+ dut.run_all_single_board_cases(name=["normal_case1", "multiple_stages_test"])
911+ """ )
912+
913+ testdir .runpytest (
914+ '-s' ,
915+ '--embedded-services' , 'esp,idf' ,
916+ '--app-path' , os .path .join (testdir .tmpdir , 'unit_test_app_esp32' ),
917+ '--log-cli-level' , 'DEBUG' ,
918+ '--junitxml' , 'report.xml' ,
919+ )
920+
921+ junit_report = ET .parse ('report.xml' ).getroot ()[0 ]
922+
923+ assert junit_report .attrib ['tests' ] == '2'
924+ for testcase in junit_report .findall ('testcase' ):
925+ assert testcase .attrib ['PYTHON_FUNC' ] == '0'
926+
927+ def test_preserve_python_tests (testdir ):
928+ testdir .makepyfile (r"""
929+ def test_python_case(dut):
930+ dut.run_all_single_board_cases(name=["normal_case1", "multiple_stages_test"])
931+ """ )
932+
933+ testdir .runpytest (
934+ '-s' ,
935+ '--embedded-services' , 'esp,idf' ,
936+ '--app-path' , os .path .join (testdir .tmpdir , 'unit_test_app_esp32' ),
937+ '--log-cli-level' , 'DEBUG' ,
938+ '--junitxml' , 'report.xml' ,
939+ '--preserve-python-tests-in-report' ,
940+ )
941+
942+ junit_report = ET .parse ('report.xml' ).getroot ()[0 ]
943+
944+ assert junit_report .attrib ['tests' ] == '2'
945+ assert junit_report [0 ].attrib ['PYTHON_FUNC' ] == '1'
946+ for testcase in junit_report [1 :]:
947+ assert testcase .attrib ['PYTHON_FUNC' ] == '0'
948+
949+
950+ def test_preserve_python_tests_with_failures (testdir ):
951+ testdir .makepyfile (r"""
952+ def test_python_case(dut):
953+ dut.run_all_single_board_cases(name=["normal_case1", "normal_case2"])
954+ """ )
955+
956+ testdir .runpytest (
957+ '-s' ,
958+ '--embedded-services' , 'esp,idf' ,
959+ '--app-path' , os .path .join (testdir .tmpdir , 'unit_test_app_esp32' ),
960+ '--log-cli-level' , 'DEBUG' ,
961+ '--junitxml' , 'report.xml' ,
962+ '--preserve-python-tests-in-report' ,
963+ )
964+
965+ junit_report = ET .parse ('report.xml' ).getroot ()[0 ]
966+
967+ assert junit_report .attrib ['failures' ] == '1'
968+ assert junit_report [0 ].attrib ['PYTHON_FUNC' ] == '1' # Python test case is preserved
969+ assert junit_report [1 ].attrib ['PYTHON_FUNC' ] == '0' # C test case
970+ assert junit_report [1 ].find ('failure' ) is None # normal_case1 passed
971+ assert junit_report [2 ].attrib ['PYTHON_FUNC' ] == '0'
972+ assert junit_report [2 ].find ('failure' ) is not None # normal_case2 failed
973+
974+
975+ def test_python_func_attribute (testdir ):
976+ testdir .makepyfile (r"""
977+ def test_python_case(dut):
978+ dut.run_all_single_board_cases(name=["normal_case1", "multiple_stages_test"])
979+ """ )
980+
981+ testdir .runpytest (
982+ '-s' ,
983+ '--embedded-services' , 'esp,idf' ,
984+ '--app-path' , os .path .join (testdir .tmpdir , 'unit_test_app_esp32' ),
985+ '--log-cli-level' , 'DEBUG' ,
986+ '--junitxml' , 'report.xml' ,
987+ '--preserve-python-tests-in-report' ,
988+ )
989+
990+ junit_report = ET .parse ('report.xml' ).getroot ()[0 ]
991+
992+ assert junit_report [0 ].attrib ['PYTHON_FUNC' ] == '1' # Python test case
993+ for testcase in junit_report [1 :]:
994+ assert testcase .attrib ['PYTHON_FUNC' ] == '0' # Other test cases
0 commit comments