• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

thetic / mutiny / 24489391918

16 Apr 2026 02:51AM UTC coverage: 98.642% (-0.1%) from 98.753%
24489391918

push

github

web-flow
Merge pull request #56 from thetic/last-exit

Add PASS_TEST/SKIP_TEST macros and improve JUnit XML skipped output

24 of 33 new or added lines in 10 files covered. (72.73%)

5084 of 5154 relevant lines covered (98.64%)

3892.25 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.94
/src/test/TestingFixture.cpp
1
#include "mutiny/test/TestingFixture.hpp"
2

3
#include "mutiny/test/ExecFunctionShell.hpp"
4
#include "mutiny/test/Result.hpp"
5
#include "mutiny/test/Shell.hpp"
6

7
namespace mu {
8
namespace tiny {
9
namespace test {
10

11
bool TestingFixture::line_of_code_executed_after_check_ = false;
12

13
void TestingFixture::replace_output(StringBufferOutput* new_output)
1 ✔
14
{
15
  delete result_;
1 ✔
16
  delete output_;
1 ✔
17
  output_ = new_output;
1 ✔
18
  result_ = new Result(*output_);
1 ✔
19
}
1 ✔
20

21
TestingFixture::TestingFixture()
146 ✔
22
{
23
  output_ = new StringBufferOutput();
146 ✔
24
  result_ = new Result(*output_);
146 ✔
25
  gen_test_ = new ExecFunctionShell();
146 ✔
26
  registry_ = new Registry();
146 ✔
27
  owns_exec_function_ = false;
146 ✔
28

29
  registry_->set_current_registry(registry_);
146 ✔
30
  registry_->add_test(gen_test_);
146 ✔
31

32
  line_of_code_executed_after_check_ = false;
146 ✔
33
}
146 ✔
34

35
void TestingFixture::flush_output_and_reset_result()
2 ✔
36
{
37
  output_->flush();
2 ✔
38
  delete result_;
2 ✔
39
  result_ = new Result(*output_);
2 ✔
40
}
2 ✔
41

42
TestingFixture::~TestingFixture()
166 ✔
43
{
44
  registry_->set_current_registry(nullptr);
146 ✔
45
  clear_exec_function();
146 ✔
46
  delete registry_;
146 ✔
47
  delete result_;
146 ✔
48
  delete output_;
146 ✔
49
  delete gen_test_;
146 ✔
50
}
166 ✔
51

52
void TestingFixture::clear_exec_function()
238 ✔
53
{
54
  if (gen_test_->test_function && owns_exec_function_)
238 ✔
55
    delete gen_test_->test_function;
91 ✔
56
}
238 ✔
57

58
void TestingFixture::add_test(Shell* test)
22 ✔
59
{
60
  registry_->add_test(test);
22 ✔
61
}
22 ✔
62

63
void TestingFixture::set_test_function(void (*test_function)())
91 ✔
64
{
65
  clear_exec_function();
91 ✔
66

67
  gen_test_->test_function = new ExecFunctionWithoutParameters(test_function);
91 ✔
68
  owns_exec_function_ = true;
91 ✔
69
}
91 ✔
70

71
void TestingFixture::set_test_function(ExecFunction* test_function)
1 ✔
72
{
73
  clear_exec_function();
1 ✔
74

75
  gen_test_->test_function = test_function;
1 ✔
76

77
  owns_exec_function_ = false;
1 ✔
78
}
1 ✔
79

80
void TestingFixture::set_setup(void (*setup_function)())
2 ✔
81
{
82
  gen_test_->setup = setup_function;
2 ✔
83
}
2 ✔
84

85
void TestingFixture::set_teardown(void (*teardown_function)())
7 ✔
86
{
87
  gen_test_->teardown = teardown_function;
7 ✔
88
}
7 ✔
89

90
void TestingFixture::install_plugin(Plugin* plugin)
1 ✔
91
{
92
  registry_->install_plugin(plugin);
1 ✔
93
}
1 ✔
94

95
void TestingFixture::set_output_verbose()
2 ✔
96
{
97
  output_->verbose(Output::MutinyVerbosityLevel::verbose);
2 ✔
98
}
2 ✔
99

100
void TestingFixture::run_test_with_method(void (*method)())
55 ✔
101
{
102
  set_test_function(method);
55 ✔
103
  run_all_tests();
55 ✔
104
}
55 ✔
105

106
void TestingFixture::run_all_tests()
114 ✔
107
{
108
  registry_->run_all_tests(*result_);
114 ✔
109
}
110 ✔
110

111
size_t TestingFixture::get_failure_count()
145 ✔
112
{
113
  return result_->get_failure_count();
145 ✔
114
}
115

116
size_t TestingFixture::get_check_count()
7 ✔
117
{
118
  return result_->get_check_count();
7 ✔
119
}
120

121
size_t TestingFixture::get_test_count()
1 ✔
122
{
123
  return result_->get_test_count();
1 ✔
124
}
125

126
size_t TestingFixture::get_ignore_count()
4 ✔
127
{
128
  return result_->get_ignored_count();
4 ✔
129
}
130

131
Registry* TestingFixture::get_registry()
28 ✔
132
{
133
  return registry_;
28 ✔
134
}
135

136
bool TestingFixture::has_test_failed()
1 ✔
137
{
138
  return gen_test_->has_failed();
1 ✔
139
}
140

141
void TestingFixture::assert_print_contains(const String& contains)
36 ✔
142
{
143
  STRCMP_CONTAINS(contains.c_str(), get_output().c_str());
36 ✔
144
}
36 ✔
145

146
void TestingFixture::assert_print_contains_not(const String& contains)
1 ✔
147
{
148
  CHECK(!string_contains(get_output(), contains));
1 ✔
149
}
1 ✔
150

151
const String& TestingFixture::get_output()
37 ✔
152
{
153
  return output_->get_output();
37 ✔
154
}
155

156
size_t TestingFixture::get_run_count()
5 ✔
157
{
158
  return result_->get_run_count();
5 ✔
159
}
160

161
void TestingFixture::line_executed_after_check()
1 ✔
162
{
163
  line_of_code_executed_after_check_ = true;
1 ✔
164
}
1 ✔
165

166
void TestingFixture::check_test_fails_with_proper_test_location(
120 ✔
167
    const char* text,
168
    const char* file,
169
    size_t line
170
)
171
{
172
  if (get_failure_count() != 1)
120 ✔
NEW
173
    FAIL_TEST_LOCATION(
×
174
        string_from_format(
175
            "Expected one test failure, but got %d amount of test failures",
176
            static_cast<int>(get_failure_count())
177
        )
178
            .c_str(),
179
        file,
180
        line
181
    );
182

183
  STRCMP_CONTAINS_LOCATION(text, output_->get_output().c_str(), "", file, line);
120 ✔
184

185
  if (line_of_code_executed_after_check_)
120 ✔
NEW
186
    FAIL_TEST_LOCATION(
×
187
        "The test should jump/throw on failure and not execute the "
188
        "next line. However, the next line was executed.",
189
        file,
190
        line
191
    );
192
}
120 ✔
193

194
} // namespace test
195
} // namespace tiny
196
} // namespace mu
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc