diff --git a/docs/src/lecture/4-julia_testing.md b/docs/src/lecture/4-julia_testing.md index 6cedb2216d7e57fee206c73e360478dce784a11b..34105cc0bc705f98fe2cfb12d0ad011829f3025c 100644 --- a/docs/src/lecture/4-julia_testing.md +++ b/docs/src/lecture/4-julia_testing.md @@ -35,7 +35,7 @@ Create a file named `test_add.jl`: ```julia using Test -include("add.jl") # Include the file containing the `add` function, or load package +using SustainableSoftwareEngineering @testset "Addition Tests" begin @test add(2, 2) == 4 @@ -70,6 +70,29 @@ This command will execute all tests defined in your project's `test` directory. #### An example output +The above testing file would yield a successful output: +```julia +julia> include("test/runtests.jl") +# Test Summary: | Pass Total Time +# Addition Tests | 4 4 0.0s +``` + +However, changing the above test file to: + +```julia +using Test +using SustainableSoftwareEngineering + +@testset "Addition Tests" begin + @test add(2, 2) == 4 + @test add(-1, 1) == 0 + @test add(0, 0) == 1 # changed 🚨 + @test_throws DomainError add("a", "b") +end +``` + +would result in an error: + ```julia # Addition Tests: Test Failed at XXX/gits/nmh/SustainableSoftwareEngineering.jl/test/test_add.jl:7 # Expression: add(0, 0) == 1