diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ef4078046e8ae4fdf3f6697d6fdc41bb13bd61b8..33b31b86cb20c9d1b04008987ea1c2501098ffef 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,17 +1,36 @@ stages: + - static-analies + - build - test - coverage + - deploy + +build: + stage: build + script: + - bazel build //... + tags: + - linux + cache: + paths: + - bazel-bin test: stage: test script: - - bazel test --instrumentation_filter=//... //... + - ./bazel-bin/test/catch2_case -o catch2_report.xml -r junit + - ./bazel-bin/test/gtest_case --gtest_output=xml:gtest_report.xml tags: - linux artifacts: when: always reports: - junit: bazel-testlogs/test/test_add/test.xml + junit: + - catch2_report.xml + - gtest_report.xml + cache: + paths: + - bazel-bin coverage: stage: coverage @@ -19,4 +38,7 @@ coverage: - linux script: - bazel coverage --combined_report=lcov --instrumentation_filter=//... --coverage_report_generator=@bazel_tools//tools/test:coverage_report_generator --javabase=@bazel_tools//tools/jdk:remote_jdk11 //... - - lcov --list bazel-out/_coverage/_coverage_report.dat \ No newline at end of file + - lcov --list bazel-out/_coverage/_coverage_report.dat + cache: + paths: + - bazel-bin \ No newline at end of file diff --git a/WORKSPACE b/WORKSPACE index 2218a09287fcc6605ab3314f25878a0b0cff993f..2c98700c5965c781b6d64f5e0e9c564d8d1e65ac 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -5,4 +5,13 @@ http_archive( urls = ["https://github.com/google/googletest/archive/refs/tags/release-1.11.0.tar.gz"], strip_prefix = "googletest-release-1.11.0", sha256 = "b4870bf121ff7795ba20d20bcdd8627b8e088f2d1dab299a031c1034eddc93d5", +) + +http_archive( + name = "com_github_catchorg_catch2", + sha256 = "48dfbb77b9193653e4e72df9633d2e0383b9b625a47060759668480fdf24fbd4", + strip_prefix = "Catch2-2.13.6", + urls = [ + "https://github.com/catchorg/Catch2/archive/refs/tags/v2.13.6.tar.gz", + ], ) \ No newline at end of file diff --git a/test/BUILD b/test/BUILD index 01f7221afca32067755e980e797d3cfcc42eabb6..6b772dfd3b0e51ade95e1607a8b088a5714fc74c 100644 --- a/test/BUILD +++ b/test/BUILD @@ -1,10 +1,20 @@ cc_test( - name = "test_add", + name = "gtest_case", srcs = ["test_add.cpp"], deps = [ "//lib:add", "@com_google_googletest//:gtest_main", ], ) + +cc_test( + name = "catch2_case", + srcs = ["test_catch2.cpp"], + deps = [ + "//lib:add", + "@com_github_catchorg_catch2//:catch2_with_main", + ], +) + diff --git a/test/test_catch2.cpp b/test/test_catch2.cpp new file mode 100644 index 0000000000000000000000000000000000000000..600d7609de334b68ac226eae61b8e977fc8060fa --- /dev/null +++ b/test/test_catch2.cpp @@ -0,0 +1,10 @@ +#include "lib/lib.hpp" + +#include "catch2/catch.hpp" + +// unit test +TEST_CASE("Factorials are computed", "[factorial]"){ + // REQUIRE + REQUIRE(add(-2, 1) == -3); + REQUIRE(add(2, 1) == 3); +}