Skip to content

Commit

Permalink
Re-factor testing framework
Browse files Browse the repository at this point in the history
 - split unittests in fast and slow tests
 - split componenttests in fast and slow tests
 - use new unittests_all as regular CI workflow
 - use new unittests_all for code coverage
  • Loading branch information
FrameConsult authored and sschlenkrich committed Mar 9, 2024
1 parent 9abafd3 commit 502c6b7
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI_componenttests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ jobs:
- uses: julia-actions/julia-buildpkg@v1
- uses: sschlenkrich/julia-runtest@with_test_arg_v3
with:
test_arg: 'componenttests/componenttests.jl'
test_arg: 'componenttests/componenttests_all.jl'
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: CI
name: CI_unittests
on:
push:
branches:
- main
tags: ['*']
pull_request:
workflow_dispatch:
concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
Expand Down Expand Up @@ -32,4 +33,6 @@ jobs:
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: sschlenkrich/julia-runtest@with_test_arg_v3
with:
test_arg: 'unittests/unittests_all.jl'
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ jobs:
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: sschlenkrich/julia-runtest@with_test_arg_v3
with:
test_arg: 'unittests/unittests_all.jl'
4 changes: 3 additions & 1 deletion .github/workflows/Codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ jobs:
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: sschlenkrich/julia-runtest@with_test_arg_v3
with:
test_arg: 'unittests/unittests_all.jl'
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v3
with:
Expand Down
26 changes: 0 additions & 26 deletions test/componenttests/componenttests.jl

This file was deleted.

13 changes: 13 additions & 0 deletions test/componenttests/componenttests_all.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using DiffFusion
using Test

@info "Start componenttests_all.jl."

@testset verbose=true "componenttests_all.jl" begin

include("componenttests_fast.jl")
include("componenttests_slow.jl")

end

@info "Start componenttests_all.jl."
18 changes: 18 additions & 0 deletions test/componenttests/componenttests_fast.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using DiffFusion
using Test

@info "Start componenttests_fast.jl."

@testset verbose=true "componenttests_fast.jl" begin

include("calibration/swap_rate_calibration.jl")

include("scenarios/asset_options.jl")
include("scenarios/bermudan_swaption.jl")
include("scenarios/rates_option.jl")
include("scenarios/scenarios.jl")
include("scenarios/swaptions_expected_exposure.jl")

end

@info "Start componenttests_fast.jl."
18 changes: 18 additions & 0 deletions test/componenttests/componenttests_slow.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using DiffFusion
using Test

@info "Start componenttests_slow.jl."

@testset verbose=true "componenttests_slow.jl" begin

include("sensitivities/forwards_deltas.jl")
include("sensitivities/option_deltas.jl")
include("sensitivities/swap_deltas.jl")
include("sensitivities/option_vegas.jl")
include("sensitivities/swaptions_delta_vega.jl")

include("sensitivities/gradients.jl")

end

@info "Start componenttests_slow.jl."
14 changes: 6 additions & 8 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@ using Logging

@testset verbose=true "DiffFusion.jl" begin

# specify default test file here
file_name = "unittests/unittests_fast.jl"
# allow amending test file via argument
if @isdefined(ARGS) && length(ARGS) > 0
@info "Run tests " * ARGS[1] * " from test_args."
@testset verbose=true "Runtests" begin
include(ARGS[1])
end
else
@testset verbose=true "Unit tests" begin
include("unittests/unittests.jl")
end
file_name = ARGS[1]
@info "Run tests " * file_name * " from test_args."
end
include(file_name)

end

Expand Down
2 changes: 0 additions & 2 deletions test/unittests/analytics/analytics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ using Test
include("scenarios.jl")
include("scenario_analytics.jl")
include("collateral.jl")
#
include("valuations.jl")

end
13 changes: 13 additions & 0 deletions test/unittests/unittests_all.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

using Test

@info "Start unittests_all.jl."

@testset verbose=true "unittests_all.jl" begin

include("unittests_fast.jl")
include("unittests_slow.jl")

end

@info "Finished unittests_all.jl."
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

using Test

@info "Start unittests.jl."
@info "Start unittests_fast.jl."

@testset verbose=true "unittests.jl" begin
@testset verbose=true "unittests_fast.jl" begin

include("analytics/analytics.jl")
include("examples/examples.jl")
Expand All @@ -18,4 +18,4 @@ using Test

end

@info "Finished unittests.jl."
@info "Finished unittests_fast.jl."
12 changes: 12 additions & 0 deletions test/unittests/unittests_slow.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

using Test

@info "Start unittests_slow.jl."

@testset verbose=true "unittests_slow.jl" begin

include("analytics/valuations.jl")

end

@info "Finished unittests_slow.jl."

0 comments on commit 502c6b7

Please sign in to comment.