diff --git a/tests/runner.d b/tests/runner.d index 1149ee7..84b6646 100644 --- a/tests/runner.d +++ b/tests/runner.d @@ -6,8 +6,14 @@ import core.stdc.string; import core.sys.posix.setjmp; import ecs.vector; +import ecs.simple_vector; import ecs.std; +unittest +{ + assert(0,"This will fail!"); +} + enum int ASSERTED = 123; enum string OUT_FILE = "test_report.xml"; @@ -33,9 +39,10 @@ struct Test string msg; int fileLine; string name; + //string classname; int time; bool passed; - bool executed; + //bool executed; } struct TestSuite @@ -87,8 +94,8 @@ void writeResult(ref TestSuite suite, ref Test result) writeToFile("\" time=\""); writeToFile(result.time); writeToFile("\" "); - writeToFile(" executed=\""); - writeToFile(cast(int) result.executed); + //writeToFile(" executed=\""); + //writeToFile(cast(int) result.executed); writeToFile("\" "); if (result.passed) @@ -147,6 +154,71 @@ struct TestRunner(Args...) uint passed = 0; uint failed = 0; + SimpleVector junit; + + void write(string txt) + { + junit.add(cast(ubyte[]) txt); + } + + void write(uint num) + { + ubyte[20] buffer; + int len; + len = sprintf(cast(char*)buffer.ptr, "%u", num); + junit.add(buffer[0..len]); + } + + void generateJUnit() + { + write("\n\n"); + + write("\n"); + + foreach(ref TestSuite suite; suites) + { + write("\t\n"); + + foreach(ref Test test; suite.tests) + { + write("\t\t\n"); + if(test.msg) + { + write("\t\t\t\n"); + write("\t\t\t\tAssert! File: "); + write(test.file[0 .. $ - 1]); + write(":"); + write(test.fileLine); + write(" Message: "); + write(test.msg[0 .. $ - 1]); + write("\n"); + write("\t\t\t\n"); + } + write("\t\t\n"); + } + + write("\t\n"); + } + + write(""); + } + void runTests() { foreach(i, module_; Args) @@ -189,7 +261,11 @@ struct TestRunner(Args...) void writeFile() { - writeTests(suites); + if(junit.length == 0)generateJUnit(); + auto file = fopen(OUT_FILE, "w"); + fwrite(junit.data.ptr,junit.length,1,file); + fclose(file); + //writeTests(suites); } void writeOutput()