LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
TestOutline.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "EventsContainer.hpp"
4
5#include <cstddef>
6#include <cstdint>
7#include <optional>
8#include <string>
9#include <string_view>
10#include <vector>
11
12namespace analyzer
13{
14
16inline constexpr std::string_view kMetaTestCase = "Test Case";
17inline constexpr std::string_view kMetaStatus = "Status";
18
31{
32 std::string timeField = "timestamp";
33 std::string typeField = "event_type";
34 std::string nameField = "info";
35 std::string textField = "payload";
36
37 std::string testStart = "TEST_START";
38 std::string testEnd = "TEST_END";
39 std::string keyword = "STEP";
40 std::string keywordFail = "STEP_FAIL";
41 std::string log = "LOG";
42
43 std::string stepMarker = "TestStep";
44 std::string expectationMarker = "TestExpectation";
45 std::string commandName = "Control command sent";
46};
47
48enum class StepStatus
49{
50 Passed,
51 Recovered,
52 Failed,
53 NotRun
54};
55
56enum class TestVerdict
57{
58 Unknown,
59 Pass,
60 Fail
61};
62
64{
65 enum class Kind
66 {
67 Section,
68 Keyword,
70 };
71
73 std::string name;
74 std::string args;
75 std::size_t firstRow {0};
76 std::size_t endRow {0};
77 std::int64_t startUs {-1};
78 std::int64_t durationUs {-1};
80 int failures {0};
81 std::string failMessage;
82 std::vector<TestStep> children;
83};
84
86{
87 std::string testName;
89 std::optional<std::size_t> testStartRow;
90 std::optional<std::size_t> testEndRow;
93 std::optional<std::size_t> decisiveFailureRow;
94 std::string failingStep;
95 std::string failureMessage;
96 std::vector<TestStep> sections;
97
99 [[nodiscard]] bool HasTest() const { return testStartRow.has_value(); }
100};
101
104[[nodiscard]] std::optional<std::int64_t> ParseIsoMicros(std::string_view ts);
105
124[[nodiscard]] TestOutline BuildTestOutline(db::EventsContainer& events,
125 const TestMarkerRules& rules = {});
126
127} // namespace analyzer
Container class for managing collections of LogEvent objects.
High-performance, thread-safe container for managing large collections of LogEvent objects.
Definition EventsContainer.hpp:129
Definition ActorDiscoverer.cpp:13
constexpr std::string_view kMetaStatus
Definition TestOutline.hpp:17
StepStatus
Definition TestOutline.hpp:49
@ Recovered
failed at least once, but the failure did not fail the test (retried, or the test passed)
@ NotRun
heuristic: logged after the decisive failure without doing anything
@ Passed
ran, no failure recorded
@ Failed
failed and was never retried in a failing test
std::optional< std::int64_t > ParseIsoMicros(std::string_view ts)
Definition TestOutline.cpp:14
TestOutline BuildTestOutline(db::EventsContainer &events, const TestMarkerRules &r)
Definition TestOutline.cpp:102
TestVerdict
Definition TestOutline.hpp:57
constexpr std::string_view kMetaTestCase
File-metadata keys of a safeAPI merged-log header (see SapiLogParser).
Definition TestOutline.hpp:16
Definition TestOutline.hpp:31
std::string keyword
a keyword starts
Definition TestOutline.hpp:39
std::string stepMarker
LOG text prefix opening a section.
Definition TestOutline.hpp:43
std::string keywordFail
a keyword failed
Definition TestOutline.hpp:40
std::string testStart
Definition TestOutline.hpp:37
std::string testEnd
Definition TestOutline.hpp:38
std::string textField
keyword arguments, failure message, marker text, test name
Definition TestOutline.hpp:35
std::string log
carries the author's step markers
Definition TestOutline.hpp:41
std::string commandName
nameField of a command to a simulator
Definition TestOutline.hpp:45
std::string timeField
Definition TestOutline.hpp:32
std::string typeField
Definition TestOutline.hpp:33
std::string expectationMarker
LOG text prefix of a checked expectation.
Definition TestOutline.hpp:44
std::string nameField
keyword name (STEP, STEP_FAIL), TEST_END verdict text
Definition TestOutline.hpp:34
Definition TestOutline.hpp:86
std::optional< std::size_t > testEndRow
Definition TestOutline.hpp:90
std::string testName
Definition TestOutline.hpp:87
std::optional< std::size_t > decisiveFailureRow
Definition TestOutline.hpp:93
TestVerdict verdict
Definition TestOutline.hpp:88
std::optional< std::size_t > testStartRow
Definition TestOutline.hpp:89
std::vector< TestStep > sections
Definition TestOutline.hpp:96
bool HasTest() const
True when the events contain a test (TEST_START), i.e. there is an outline to show.
Definition TestOutline.hpp:99
std::string failingStep
keyword name of the decisive failure (empty: none recorded)
Definition TestOutline.hpp:94
std::string failureMessage
its message
Definition TestOutline.hpp:95
Definition TestOutline.hpp:64
std::string name
section title, keyword name or marker text
Definition TestOutline.hpp:73
std::int64_t startUs
start relative to TEST_START in µs; -1 = no timestamp
Definition TestOutline.hpp:77
Kind
Definition TestOutline.hpp:66
@ Keyword
one STEP event
@ Expectation
one TestExpectation … marker
@ Section
Setup, one TestStep N: … marker, or Teardown.
std::string args
keyword arguments (keywords only)
Definition TestOutline.hpp:74
std::vector< TestStep > children
keywords and expectations of a section
Definition TestOutline.hpp:82
Kind kind
Definition TestOutline.hpp:72
std::size_t firstRow
EventsContainer index of the step's first event.
Definition TestOutline.hpp:75
StepStatus status
Definition TestOutline.hpp:79
int failures
STEP_FAIL events of this step (sections: of their children)
Definition TestOutline.hpp:80
std::int64_t durationUs
until the next step starts, in µs; -1 = unknown
Definition TestOutline.hpp:78
std::size_t endRow
one past the step's last event
Definition TestOutline.hpp:76
std::string failMessage
message of the step's last failure
Definition TestOutline.hpp:81