Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/Progmasoft/Catch3/Results.hpp
blob: b0b69b55a59659a73d26beafa385bf860702a2a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (c) 2026 Progmasoft.
// SPDX-License-Identifier: MPL-2.0 WITH AdditionRef-Progmasoft-Exception-1.1
#pragma once

#include <cstddef>
#include <string>
#include <vector>

namespace Progmasoft::Catch3 {

    enum class TestCaseStatus : unsigned char {
        kPassed,
        kFailed,
        kErrored,
        kSkipped,
    };

    /// Framework-neutral result for one completed test case.
    struct TestCaseResult final {
        std::string Name;
        std::string ClassName;
        std::string SourceFile;
        TestCaseStatus Status = TestCaseStatus::kPassed;
        double DurationSeconds = 0.0;
        std::string Message;
        std::string Details;
        std::string StandardOutput;
        std::string StandardError;
    };

    struct TestSuiteResult final {
        std::string Name;
        std::vector<TestCaseResult> TestCases;
    };

    struct TestRunResult final {
        std::string Name;
        std::vector<TestSuiteResult> TestSuites;
    };

    struct TestRunSummary final {
        std::size_t Tests = 0;
        std::size_t Failures = 0;
        std::size_t Errors = 0;
        std::size_t Skipped = 0;
        double DurationSeconds = 0.0;

        [[nodiscard]] std::size_t Passed() const noexcept;
    };

    /// Validates durations and statuses while aggregating nested test results.
    [[nodiscard]] TestRunSummary
    SummarizeTestSuite( const TestSuiteResult& result );
    [[nodiscard]] TestRunSummary
    SummarizeTestRun( const TestRunResult& result );

} // namespace Progmasoft::Catch3