Add material for testing (#11)
* Add first draft material for testing * added some first test stuff in julia * add asserti error * Rework intro slides * added package * Wrap up testing slides expect demo * Smooth demo part * Add statement on tests * Remove previous python exercise file --------- Co-authored-by: behinger (s-ccs 001) <benedikt.ehinger@vis.uni-stuttgart.de>
This commit is contained in:
committed by
GitHub
parent
e6f7ff3ed1
commit
937a8a9481
40
material/2_tue/testing/MyTestPackage/test/Manifest.toml
Normal file
40
material/2_tue/testing/MyTestPackage/test/Manifest.toml
Normal file
@@ -0,0 +1,40 @@
|
||||
# This file is machine-generated - editing it directly is not advised
|
||||
|
||||
julia_version = "1.9.2"
|
||||
manifest_format = "2.0"
|
||||
project_hash = "c34966543d8e8dc43716ca8888b0447b9c23c175"
|
||||
|
||||
[[deps.Base64]]
|
||||
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
|
||||
|
||||
[[deps.InteractiveUtils]]
|
||||
deps = ["Markdown"]
|
||||
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
|
||||
|
||||
[[deps.Logging]]
|
||||
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
|
||||
|
||||
[[deps.Markdown]]
|
||||
deps = ["Base64"]
|
||||
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
|
||||
|
||||
[[deps.Random]]
|
||||
deps = ["SHA", "Serialization"]
|
||||
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
|
||||
|
||||
[[deps.SHA]]
|
||||
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
|
||||
version = "0.7.0"
|
||||
|
||||
[[deps.Serialization]]
|
||||
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
|
||||
|
||||
[[deps.StableRNGs]]
|
||||
deps = ["Random", "Test"]
|
||||
git-tree-sha1 = "3be7d49667040add7ee151fefaf1f8c04c8c8276"
|
||||
uuid = "860ef19b-820b-49d6-a774-d7a799459cd3"
|
||||
version = "1.0.0"
|
||||
|
||||
[[deps.Test]]
|
||||
deps = ["InteractiveUtils", "Logging", "Random", "Serialization"]
|
||||
uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
|
||||
3
material/2_tue/testing/MyTestPackage/test/Project.toml
Normal file
3
material/2_tue/testing/MyTestPackage/test/Project.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
[deps]
|
||||
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
|
||||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
|
||||
34
material/2_tue/testing/MyTestPackage/test/find.jl
Normal file
34
material/2_tue/testing/MyTestPackage/test/find.jl
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
@testset "unit tests" begin
|
||||
@testset "find_max" begin
|
||||
@test find_max([1,2,3]) == 3
|
||||
@test find_max([0,0,0]) == 0
|
||||
|
||||
@test_throws AssertionError find_max([NaN,3,2])
|
||||
end
|
||||
|
||||
@testset "find_mean" begin
|
||||
@test find_mean([1,2,3]) == 2
|
||||
@test find_mean([1,3,6]) ≈ 3.333 atol=1e-3
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@testset "integration test" begin
|
||||
|
||||
data1 = [43, 32, 167, 18, 1, 209]
|
||||
data2 = [3, 13, 33, 23, 498]
|
||||
|
||||
# Expected result
|
||||
expected_mean_of_max = 353.5
|
||||
|
||||
maximum1 = find_max(data1)
|
||||
maximum2 = find_max(data2)
|
||||
|
||||
# Actual result
|
||||
actual_mean_of_max = find_mean([maximum1, maximum2])
|
||||
|
||||
# Test
|
||||
@test actual_mean_of_max == expected_mean_of_max
|
||||
|
||||
end
|
||||
7
material/2_tue/testing/MyTestPackage/test/runtests.jl
Normal file
7
material/2_tue/testing/MyTestPackage/test/runtests.jl
Normal file
@@ -0,0 +1,7 @@
|
||||
using MyTestPackage # here it is ok to use, don't put it in your "debug"-convenience setup.jl
|
||||
include("setup.jl")
|
||||
|
||||
|
||||
@testset "find" begin
|
||||
include("find.jl")
|
||||
end
|
||||
2
material/2_tue/testing/MyTestPackage/test/setup.jl
Normal file
2
material/2_tue/testing/MyTestPackage/test/setup.jl
Normal file
@@ -0,0 +1,2 @@
|
||||
using Test
|
||||
using StableRNGs
|
||||
Reference in New Issue
Block a user