aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/testing/Testing.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/openvic-simulation/testing/Testing.cpp')
-rw-r--r--src/openvic-simulation/testing/Testing.cpp63
1 files changed, 55 insertions, 8 deletions
diff --git a/src/openvic-simulation/testing/Testing.cpp b/src/openvic-simulation/testing/Testing.cpp
index fcfe2cc..4d3d9ea 100644
--- a/src/openvic-simulation/testing/Testing.cpp
+++ b/src/openvic-simulation/testing/Testing.cpp
@@ -1,15 +1,10 @@
#include <testing/Testing.hpp>
#include <testing/TestScript.hpp>
+#include <fstream>
using namespace OpenVic;
-Testing::Testing(GameManager& g_manager)
- : game_manager { g_manager },
- map { g_manager.get_map() },
- building_manager { g_manager.get_building_manager() },
- good_manager { g_manager.get_good_manager() },
- pop_manager { g_manager.get_pop_manager() },
- clock { g_manager.get_clock() } {
+Testing::Testing(GameManager* game_manager) {
// Constructor for the tests will add requirements
// Then execute the script
@@ -25,6 +20,10 @@ Testing::Testing(GameManager& g_manager)
test_scripts.push_back(a_005_nation_tests);
A_006_politics_tests* a_006_politics_tests = new A_006_politics_tests();
test_scripts.push_back(a_006_politics_tests);
+
+ for (int i = 0; i < test_scripts.size(); i++) {
+ test_scripts[i]->set_game_manager(game_manager);
+ }
}
Testing::~Testing() {
@@ -33,10 +32,58 @@ Testing::~Testing() {
}
}
-void Testing::report_results() {
+void Testing::execute_all_scripts() {
for (int i = 0; i < test_scripts.size(); i++) {
+ test_scripts[i]->execute_script();
+ }
+}
+
+void Testing::report_results() {
+ std::ofstream test_results;
+ // _mkdir("..\\src\\openvic - simulation\\testing\\test_results"); - replace with compatible version (boost?)
+ test_results.open("..\\src\\openvic-simulation\\testing\\test_results\\results.txt");
+ for (auto test_script : test_scripts) {
+ std::vector<OpenVic::Requirement*> reqs = test_script->get_requirements();
+ std::vector<OpenVic::Requirement*> passed_reqs = test_script->get_passed_requirements();
+ std::vector<OpenVic::Requirement*> failed_reqs = test_script->get_failed_requirements();
+ std::vector<OpenVic::Requirement*> untested_reqs = test_script->get_untested_requirements();
+
+ test_results << test_script->get_script_name() << ":" << std::endl;
+ test_results << "\t" << "Requirements for Test" << std::endl;
+ test_results << "\t";
+ for (auto req : reqs) {
+ test_results << req->get_id() << " ";
+ }
+ if (reqs.size() < 1) test_results << "None";
+ test_results << std::endl << std::endl;
+
+ test_results << "\t"<< "Passed Requirements" << std::endl;
+ test_results << "\t";
+ for (auto req : passed_reqs) {
+ test_results << req->get_id() << " ";
+ }
+ if (passed_reqs.size() < 1) test_results << "None";
+ test_results << std::endl << std::endl;
+
+ test_results << "\t" << "Failed Requirements" << std::endl;
+ test_results << "\t";
+ for (auto req : failed_reqs) {
+ test_results << req->get_id() << " ";
+ }
+ if (failed_reqs.size() < 1) test_results << "None";
+ test_results << std::endl << std::endl;
+
+ test_results << "\t" << "Untested Requirements" << std::endl;
+ test_results << "\t";
+ for (auto req : untested_reqs) {
+ test_results << req->get_id() << " ";
+ }
+ if (untested_reqs.size() < 1) test_results << "None";
+ test_results << std::endl << std::endl;
+ test_results << std::endl<< std::endl;
}
+ test_results.close();
// Create Summary File