Unittests and windows application
Stefan via Digitalmars-d
digitalmars-d at puremagic.com
Thu Mar 26 03:23:56 PDT 2015
I am currently porting a D1 application to D2. I am trying to
take advantage of new language features but mostly of the "new"
standard library features.
The old application has several unit tests and I would like to
have them executed to secure that everything works as expected.
The problem with the unit tests is that they will be executed but
I can not see the results because errors will be written to
console output which is not available in a windows application.
I did a little bit of research and found this two similar threads:
-
http://stackoverflow.com/questions/27580107/why-is-unit-testing-not-working-in-this-d-program
-
http://forum.dlang.org/thread/joiglupanlvejarmsukd@forum.dlang.org
But they just explain why that does not work.
Interestingly enough, the hint in the first thread to use the
standard D main method instead of a WinMain
(http://wiki.dlang.org/D_for_Win32) works for me. I just specify
a *.def with SUBSYSTEM WINDOWS.
Class runtime.d seems to contain the code that performs the unit
tests: bool runModuleUnitTests()
Runtime has a @property moduleUnitTester which can be set to a
function that runs the unit test of a given module. If this is
property is set it will be used otherwise a default test runner
will be executed. This default test runner will report any error
with the internal function void printErr(in char[] buf).
The question is where should the error output go in a windows
application. Possible solutions maybe:
- write that to file similar to the code coverage *.lst
- write it to windows debug view with win32: void
OutputDebugStringA( LPCTSTR lpOutputString )
I will try set the modultUnitTester property and use
OutputDebugView. Although, not very nice because a lot of code
has to be copied.
Are there any other options?
More information about the Digitalmars-d
mailing list