linkrope / dunit

xUnit Testing Framework for D
Boost Software License 1.0
37 stars 9 forks source link

Test Feedback #10

Closed kingsleyh closed 8 years ago

kingsleyh commented 8 years ago

Hi

I'm trying to hook d-unit support into my intellij plugin for D here: https://github.com/kingsleyh/DLanguage

How can I get test result information while the test is running so that I can feed it into my test reporter? The readme also mentioned an XML report but doesn't say how to get it - and if its generated only at the end of the run or progressively updated?

linkrope commented 8 years ago

The XML test report can be requested with the command-line argument --report FILE. A std.xml document tree is created, but only finally it is serialized and written to a file.

The dunit.framework, however, defines and uses a TestListener interface. The implementations of this interface other than the XmlReporter, write progressively to standard output.

kingsleyh commented 8 years ago

Great thanks for the information.

Currently I find a list of tests to run in the IDE and then iterate the list and execute each one using --filter and I parser the -v output to get the result. I though it might be nice to have the xml output written to stdout and then I could parse that instead. I can work ok with the way it's currently working - but it might be nice to have another option to write the report out to stdout e.g.:

    bool stdOutReport = false;

    "stdout|o", "Write JUnit-style XML test report to stdout",
        &stdOutReport,

    public void exit()
    {
    import std.file;

    string report = join(this.document.pretty(4), "\n") ~ "\n";

    if (stdOutReport)
    {
        writeln(report);
    }
    else
    {
        write(this.fileName, report);
    }
   }

No sure how you feel about that. I would like to provide awesome test support in the IDE - so maybe we could come up with some improvements or new features to make the testing experience even more awesome?

Here is an early preview of the test runner I have so far:

https://raw.githubusercontent.com/kingsleyh/DLanguage/testrunnerspike/.README/d-unit-support.png

linkrope commented 8 years ago

Please, try the --xml option introduced with the latest commit: <testcase> elements are written progressively to standard output.

A new challenge is that there is no longer a root element for these <testcase> elements. Let me know whether you can handle this.

kingsleyh commented 8 years ago

Awesome thanks - I will try it out