Test summary in julia 0.6

I am trying to implement test code example from this page: http://docs.julialang.org/en/latest/stdlib/test.html

julia> using Base.Test

julia> foo(x) = length(x)^2
foo (generic function with 1 method)

julia> @testset "Foo Tests" begin
                  @testset "Animals" begin
                      @testset "Felines" begin
                          @test foo("cat") == 9
                      end
                      @testset "Canines" begin
                          @test foo("dog") == 9
                      end
                  end
                  @testset "Arrays" begin
                      @test foo(zeros(2)) == 4
                      @test foo(ones(4)) == 15
                  end
              end
Arrays: Test Failed
  Expression: foo(ones(4)) == 15
   Evaluated: 16 == 15
Stacktrace:
 [1] macro expansion; at ./REPL[3]:12 [inlined]
 [2] macro expansion; at ./test.jl:801 [inlined]
 [3] macro expansion; at ./REPL[3]:0 [inlined]
 [4] macro expansion; at ./test.jl:801 [inlined]
 [5] anonymous at ./<missing>:?
ERROR: Some tests did not pass: 3 passed, 1 failed, 0 errored, 0 broken.

but i do not get this test summary in output:

Test Summary: | Pass  Fail  Total
Foo Tests     |    3     1      4
  Animals     |    2            2
  Arrays      |    1     1      2

I am using this julia version:

julia> versioninfo()
Julia Version 0.6.0-dev.2021
Commit 6b1b4f6 (2017-01-10 01:39 UTC)

There is nice test summary output in julia 0.5. Is it possible to get it back somehow?

1 Like

Hmm, actually the @testset summary doesn’t print even when the tests are successful. Not sure if this was intentional, see https://github.com/JuliaLang/julia/pull/18738#issuecomment-272634901

You can manually print the result with:

julia> r = @testset "Foo Tests" begin
               ...

julia> Base.Test.print_test_results(r)
Test Summary: | Pass  Total
  Foo Tests   |    4      4
2 Likes

Thank you, it is very useful.

I’ve made a pull request that should bring this back https://github.com/JuliaLang/julia/pull/20221

3 Likes