A very simple testing framework that rejects all previous testing designs and aims for plain wording, simple usability, and ease of debugging. You will never ask where a failure was ever again.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
fuc2/src/run.cpp

46 lines
1.1 KiB

#include <string>
#include <fmt/core.h>
#include <fuc2/run.hpp>
namespace fuc2 {
int run(const Set& test_set) {
int fail_count = 0;
std::vector<std::string> errors;
fmt::println("################# {} \"{}\" ###############",
test_set.location.file_name(), test_set.name);
for(const auto& [name, test] : test_set.tests) {
bool did_fail = false;
fmt::println("----------- START {}", name);
try {
test();
} catch(const std::exception& e) {
fail_count++;
did_fail = true;
fmt::println("🚨 FAIL! {}", e.what());
errors.push_back(e.what());
if(test_set.options.fail_fast) {
break;
}
}
std::string pass_fail = did_fail ? "🔴" : "🟢";
fmt::println("{} {}\n==========", pass_fail, name);
}
if(fail_count > 0) {
fmt::println("🚨🚨🚨🚨🚨 FAIL COUNT: {} in {}", fail_count, test_set.location.file_name());
for(auto& msg : errors) {
fmt::println("---------\n{}", msg);
}
} else {
fmt::println("👍 ALL PASS: {}", test_set.location.file_name());
}
return fail_count;
}
}