diff --git a/src/testsets.jl b/src/testsets.jl index 946e065..6d9aca3 100644 --- a/src/testsets.jl +++ b/src/testsets.jl @@ -261,7 +261,7 @@ function _flatten_results!(ts::AbstractTestSet)::Vector{<:AbstractTestSet} if !isempty(results) || has_new_properties # Use same ts to preserve description ts.results = results - push!(flattened_results, ts) + pushfirst!(flattened_results, ts) end return flattened_results end diff --git a/test/recordproperty.jl b/test/recordproperty.jl index abe28ae..a169965 100644 --- a/test/recordproperty.jl +++ b/test/recordproperty.jl @@ -44,15 +44,22 @@ properties_nodes = lastnode.(elements(root(rep))) # Child properties are first in report - @test elements(properties_nodes[1])[1]["name"] == "Prop" - @test elements(properties_nodes[1])[1]["value"] == "Inner 1" - @test elements(properties_nodes[1])[2]["name"] == "ID" - @test elements(properties_nodes[1])[2]["value"] == "TopLevel" + @test length(elements(properties_nodes[1])) == 1 + @test elements(properties_nodes[1])[1]["name"] == "ID" + @test elements(properties_nodes[1])[1]["value"] == "TopLevel" + + @test length(elements(properties_nodes[2])) == 2 @test elements(properties_nodes[2])[1]["name"] == "Prop" - @test elements(properties_nodes[2])[1]["value"] == "Inner 2" + @test elements(properties_nodes[2])[1]["value"] == "Inner 1" @test elements(properties_nodes[2])[2]["name"] == "ID" @test elements(properties_nodes[2])[2]["value"] == "TopLevel" + @test length(elements(properties_nodes[3])) == 2 + @test elements(properties_nodes[3])[1]["name"] == "Prop" + @test elements(properties_nodes[3])[1]["value"] == "Inner 2" + @test elements(properties_nodes[3])[2]["name"] == "ID" + @test elements(properties_nodes[3])[2]["value"] == "TopLevel" + # Test full packaage pkg = "TestsWithProperties" temp_pkg_dir() do tmp @@ -88,7 +95,7 @@ # Force flattening as ts doesn't finish fully as it is not the top level testset overwrite_text = "Property ID in testest Outer overwritten by child testset Inner" @test_logs (:warn, overwrite_text) TestReports.flatten_results!(ts) - @test ts.results[1].properties["ID"] == "0" + @test ts.results[2].properties["ID"] == "0" # Test for parent testset properties not being applied to child due to different type ts = @testset ReportingTestSet "" begin diff --git a/test/references/complexexample.txt b/test/references/complexexample.txt index 80e09e4..7221463 100644 --- a/test/references/complexexample.txt +++ b/test/references/complexexample.txt @@ -1,16 +1,19 @@ -Test Failed +Test Failed + Expression: sqrt(20) == 5 + Evaluated: 4.47213595499958 == 5 +Test Failed Expression: 1 * 2 == 5 Evaluated: 2 == 5 -Test Failed - Expression: 1 + -2 == 1 - Evaluated: -1 == 1 -Test Failed +Test Failed Expression: 1 + 2 == 5 Evaluated: 3 == 5 -Nooo -Outside of tests -Test Failed +Test Failed + Expression: 1 + -2 == 1 + Evaluated: -1 == 1 +Nooo +Outside of tests +Test Failed Expression: throw(ArgumentError("1")) Expected: DimensionMismatch Thrown: ArgumentError @@ -18,8 +21,5 @@ Expression: true Expected: DimensionMismatch No exception thrown -Test Failed - Expression: sqrt(20) == 5 - Evaluated: 4.47213595499958 == 5 - + diff --git a/test/references/complexexample_pre_1_7.txt b/test/references/complexexample_pre_1_7.txt index 29871ad..c2dfd50 100644 --- a/test/references/complexexample_pre_1_7.txt +++ b/test/references/complexexample_pre_1_7.txt @@ -1,19 +1,19 @@ -Test Failed +Test Failed + Expression: sqrt(20) == 5 + Evaluated: 4.47213595499958 == 5Test Failed Expression: 1 * 2 == 5 - Evaluated: 2 == 5Test Failed - Expression: 1 + -2 == 1 - Evaluated: -1 == 1Test Failed + Evaluated: 2 == 5Test Failed Expression: 1 + 2 == 5 - Evaluated: 3 == 5Nooo -Outside of tests -Test Failed + Evaluated: 3 == 5Test Failed + Expression: 1 + -2 == 1 + Evaluated: -1 == 1Nooo +Outside of tests +Test Failed Expression: throw(ArgumentError("1")) Expected: DimensionMismatch Thrown: ArgumentErrorTest Failed Expression: true Expected: DimensionMismatch - No exception thrownTest Failed - Expression: sqrt(20) == 5 - Evaluated: 4.47213595499958 == 5 + No exception thrown diff --git a/test/references/complexexample_pre_1_9.txt b/test/references/complexexample_pre_1_9.txt index c236b76..2efba2e 100644 --- a/test/references/complexexample_pre_1_9.txt +++ b/test/references/complexexample_pre_1_9.txt @@ -1,19 +1,19 @@ -Test Failed +Test Failed + Expression: sqrt(20) == 5 + Evaluated: 4.47213595499958 == 5Test Failed Expression: 1 * 2 == 5 - Evaluated: 2 == 5Test Failed - Expression: 1 + -2 == 1 - Evaluated: -1 == 1Test Failed + Evaluated: 2 == 5Test Failed Expression: 1 + 2 == 5 - Evaluated: 3 == 5Nooo -Outside of tests -Test Failed + Evaluated: 3 == 5Test Failed + Expression: 1 + -2 == 1 + Evaluated: -1 == 1Nooo +Outside of tests +Test Failed Expression: throw(ArgumentError("1")) Expected: DimensionMismatch Thrown: ArgumentErrorTest Failed Expression: true Expected: DimensionMismatch - No exception thrownTest Failed - Expression: sqrt(20) == 5 - Evaluated: 4.47213595499958 == 5 + No exception thrown diff --git a/test/references/test_with_properties.txt b/test/references/test_with_properties.txt index b952e19..5d766ce 100644 --- a/test/references/test_with_properties.txt +++ b/test/references/test_with_properties.txt @@ -1,2 +1,2 @@ - + diff --git a/test/references/test_with_properties_pre_1_7.txt b/test/references/test_with_properties_pre_1_7.txt index c885668..d51c36d 100644 --- a/test/references/test_with_properties_pre_1_7.txt +++ b/test/references/test_with_properties_pre_1_7.txt @@ -1,2 +1,2 @@ - + diff --git a/test/testsets.jl b/test/testsets.jl index e11807b..0e446cc 100644 --- a/test/testsets.jl +++ b/test/testsets.jl @@ -73,8 +73,8 @@ end flattened_results = TestReports._flatten_results!(ts) @test length(flattened_results) == 2 @test all(isa.(flattened_results, AbstractTestSet)) - @test flattened_results[1].description == "Nested/1/2/3" - @test flattened_results[2].description == "Nested/1/2" + @test flattened_results[1].description == "Nested/1/2" + @test flattened_results[2].description == "Nested/1/2/3" end @testset "ReportingTestSet Display" begin @@ -211,4 +211,4 @@ end end end end -end \ No newline at end of file +end