linkrope / dunit Goto Github PK
View Code? Open in Web Editor NEWThis project forked from jmcabo/dunit
xUnit Testing Framework for D
License: Boost Software License 1.0
This project forked from jmcabo/dunit
xUnit Testing Framework for D
License: Boost Software License 1.0
I am still new to Dlang, so it's possible this is user error. I am using:
$dmd -v
DMD64 D Compiler v2.065
I tried including dunit in a project I am building and I get these errors when I just have the dependency in dub.json
& the import statement in my app.d
:
Running dmd...
../../../.dub/packages/d-unit-0.7.2/src/dunit/framework.d(57): Error: undefined identifier GetoptResult
../../../.dub/packages/d-unit-0.7.2/src/dunit/framework.d(71): Error: undefined identifier GetOptException
../../../.dub/packages/d-unit-0.7.2/src/dunit/framework.d(73): Error: undefined identifier exception, did you mean class Exception?
../../../.dub/packages/d-unit-0.7.2/src/dunit/framework.d(81): Error: undefined identifier defaultGetoptPrinter
I believe the getopt interface has changed because I can build the following, which uses getopt pretty differently to how dunit uses it:
import std.getopt;
string data = "file.dat";
int length = 24;
bool verbose;
void main(string[] args)
{
getopt(
args,
"length", &length, // numeric
"file", &data, // string
"verbose", &verbose // flag
);
}
I execute dub test
and get following output in the terminal of Visual Studio Code
There was 1 failure:
1) client.tests.tasks.login.LoginV3Test.askForApiEndpoint
dunit.assertion.AssertException@source/client/tests/tasks/login.d(54): expected: <<https://myapi/v3>> but was: <<>>
Visual Studio Code automatically enables forward navigation to line 54 of source code file source/client/tests/tasks/login.d
if the output e.g. looks like this:
There was 1 failure:
1) client.tests.tasks.login.LoginV3Test.askForApiEndpoint
source/client/tests/tasks/login.d(54): expected:
<<https://myapi/v3>> but was: <<>>
The @
character before the source file location is an issue.
Do you see any chance to change the output to a VSC friendly format?
The latest tagged version (v0.7.1) does not properly compile without warnings on DMD 2.067.1. Please keep tagging new releases so we can use DUB to upgrade instead of having to override to "~master" in dub.selections.json
You can name your unittest in D:
@("simple test") unittest
{
assert(1 ==1);
}
This name could also be used in d-unit
SonarQube has a generic test execution report format [1]
<testExecutions version="1">
<file path="testx/ClassOneTest.xoo">
<testCase name="test1" duration="5"/>
<testCase name="test2" duration="500">
<skipped message="short message">other</skipped>
</testCase>
<testCase name="test3" duration="100">
<failure message="short">stacktrace</failure>
</testCase>
<testCase name="test4" duration="500">
<error message="short">stacktrace</error>
</testCase>
</file>
</testExecutions>
If d-unit could also produce a report in this format, the results can directly be imported
into SonarQube.
PS. At the moment SonarQube fails if in attribute "path" a file with extension ".d" is specified.
I opened a ticket on SonarQube, they will fix this issue.
[1] https://docs.sonarqube.org/latest/analysis/generic-test/
I would like to test whether a struct is initial or not.
As workaround assertTrue, assertSame could be used but two new assertions assertInitial
and assertNotInitial
would be more expressive.
The value of test suite is hard coded to "dunit".
https://github.com/linkrope/dunit/blob/master/src/dunit/framework.d#L695
It would be nice if I can change this value.
Scenario: I compile my applications for windows/linux/mac os. Also for each os a xml report is created and shown in a Jenkins plugin. As these 3 xml reports have the same test suite value and the same tests, they are aggregated and looks like each test is listed 3 times.I would like to set the test suite value to "dunit-"~operationSystemName.
With this change the Jenkins plugin would show 3 independent test result sets.
With the newest beta of D (2.067.0-b4) there will be warnings thrown because of the usage of .array property in assertion.d line 173.
This issue can easily be fixed by using std.algorithm.sort
The D linter tool D-Scanner has some style checks findings. Whether there are also syntax check findings at the moment I am not able to check due to a bug in D-Scanner
.\dependencies\d-unit-0.8.1\d-unit\example.d(29:17)[warn]: Public declaration 'assertEqualsFailure' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\example.d(38:17)[warn]: Public declaration 'assertAssocArrayEqualsFailure' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\example.d(47:17)[warn]: Public declaration 'assertRangeEqualsFailure' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\example.d(56:17)[warn]: Public declaration 'assertAllFailure' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\example.d(75:12)[warn]: Public declaration is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\example.d(87:24)[warn]: Public declaration 'tearDownAll' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\example.d(99:17)[warn]: Public declaration 'tearDown' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\example.d(105:17)[warn]: Public declaration 'test1' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\example.d(111:17)[warn]: Public declaration 'test2' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\example.d(140:17)[warn]: Public declaration 'testResult' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\example.d(158:17)[warn]: Public declaration 'failure' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\example.d(165:17)[warn]: Public declaration 'error' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\example.d(172:17)[warn]: Public declaration 'testException' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\example.d(201:17)[warn]: Public declaration 'tearDown' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\example.d(214:17)[warn]: Public declaration 'test' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\fluent_assertions.d(20:17)[warn]: Public declaration 'shouldEqualFailure' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\fluent_assertions.d(26:17)[warn]: Public declaration 'shouldNotEqualFailure' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\fluent_assertions.d(32:17)[warn]: Public declaration 'shouldBeInFailure' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\assertion.d(23:24)[warn]: Public declaration is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\assertion.d(37:23)[warn]: Public declaration 'exceptions' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\assertion.d(39:24)[warn]: Public declaration is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\assertion.d(44:22)[warn]: a virtual call inside a constructor may lead to unexpected results in the derived classes
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\assertion.d(51:38)[warn]: Public declaration 'heading' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\assertion.d(60:27)[warn]: Public declaration 'description' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\assertion.d(286:12)[warn]: Variable index initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\assertion.d(489:23)[warn]: Variable exceptions initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\attributes.d(3:6)[warn]: Public declaration 'AfterEach' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\attributes.d(4:6)[warn]: Public declaration 'AfterAll' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\attributes.d(5:6)[warn]: Public declaration 'BeforeEach' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\attributes.d(6:6)[warn]: Public declaration 'BeforeAll' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\attributes.d(7:6)[warn]: Public declaration 'Test' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\attributes.d(9:8)[warn]: Public declaration 'Disabled' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\attributes.d(11:12)[warn]: Public declaration 'reason' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\attributes.d(14:8)[warn]: Public declaration 'Tag' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\attributes.d(16:12)[warn]: Public declaration 'name' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\color.d(10:6)[warn]: Public declaration 'Color' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\color.d(14:17)[warn]: Public declaration 'writec' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\color.d(54:21)[warn]: Variable useColor initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\color.d(55:21)[warn]: Variable computed initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\color.d(60:20)[warn]: Local imports should specify the symbols being imported to avoid hiding local symbols.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\color.d(71:17)[warn]: Public declaration 'writec' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\color.d(75:20)[warn]: Local imports should specify the symbols being imported to avoid hiding local symbols.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\color.d(121:21)[warn]: Variable useColor initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\color.d(122:21)[warn]: Variable computed initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\color.d(127:20)[warn]: Local imports should specify the symbols being imported to avoid hiding local symbols.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\diff.d(19:10)[warn]: Variable oneLiner is never modified and could have been declared const or immutable.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(22:8)[warn]: Public declaration 'TestClass' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(24:12)[warn]: Public declaration 'name' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(25:14)[warn]: Public declaration 'tests' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(26:22)[warn]: Public declaration 'disabled' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(27:19)[warn]: Public declaration 'tags' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(29:23)[warn]: Public declaration 'create' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(30:21)[warn]: Public declaration 'beforeAll' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(31:29)[warn]: Public declaration 'beforeEach' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(32:42)[warn]: Public declaration 'test' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(33:29)[warn]: Public declaration 'afterEach' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(34:21)[warn]: Public declaration 'afterAll' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(37:13)[warn]: Public declaration 'testClasses' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(39:8)[warn]: Public declaration 'TestSelection' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(41:15)[warn]: Public declaration 'testClass' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(42:14)[warn]: Public declaration 'tests' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(45:16)[warn]: Public declaration 'Main' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(53:12)[warn]: Public declaration 'dunit_main' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(55:12)[warn]: Local imports should specify the symbols being imported to avoid hiding local symbols.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(56:12)[warn]: Local imports should specify the symbols being imported to avoid hiding local symbols.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(57:12)[warn]: Local imports should specify the symbols being imported to avoid hiding local symbols.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(60:14)[warn]: Variable filters initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(61:14)[warn]: Variable includeTags initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(62:14)[warn]: Variable excludeTags initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(63:10)[warn]: Variable list initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(64:12)[warn]: Variable report initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(65:10)[warn]: Variable verbose initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(66:10)[warn]: Variable xml initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(97:21)[warn]: Variable testSelections initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(221:13)[warn]: Public declaration 'matches' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(226:13)[warn]: Public declaration 'runTests' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(264:16)[warn]: Catching Error or Throwable is almost always a bad idea.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(277:14)[warn]: Variable initialized initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(278:14)[warn]: Variable setUp initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(283:18)[warn]: Variable success initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(342:34)[warn]: Variable testListeners initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(344:11)[warn]: Public declaration 'TestListener' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(346:17)[warn]: Public declaration 'enterClass' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(347:17)[warn]: Public declaration 'enterTest' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(348:17)[warn]: Public declaration 'skip' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(349:17)[warn]: Public declaration 'addFailure' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(350:17)[warn]: Public declaration 'addError' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(351:17)[warn]: Public declaration 'exitTest' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(352:17)[warn]: Public declaration 'exit' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(354:26)[warn]: Public declaration 'prettyOrigin' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(364:26)[warn]: Public declaration 'prettyOrigin' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(380:7)[warn]: Public declaration 'IssueReporter' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(390:21)[warn]: Variable failures initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(391:21)[warn]: Variable errors initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(395:17)[warn]: Public declaration 'enterClass' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(400:17)[warn]: Public declaration 'enterTest' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(405:17)[warn]: Public declaration 'skip' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(405:29)[warn]: Parameter reason is never used.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(410:17)[warn]: Public declaration 'addFailure' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(416:17)[warn]: Public declaration 'addError' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(422:17)[warn]: Public declaration 'exitTest' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(428:17)[warn]: Public declaration 'exit' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(471:7)[warn]: Public declaration 'DetailReporter' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(476:17)[warn]: Public declaration 'enterClass' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(481:17)[warn]: Public declaration 'enterTest' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(487:17)[warn]: Public declaration 'skip' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(495:17)[warn]: Public declaration 'addFailure' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(502:17)[warn]: Public declaration 'addError' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(510:17)[warn]: Public declaration 'exitTest' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(514:20)[warn]: Variable elapsed is never modified and could have been declared const or immutable.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(521:17)[warn]: Public declaration 'exit' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(532:7)[warn]: Public declaration 'ResultReporter' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(534:18)[warn]: Variable tests initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(535:18)[warn]: Variable failures initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(536:18)[warn]: Variable errors initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(537:18)[warn]: Variable skips initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(539:17)[warn]: Public declaration 'enterClass' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(539:35)[warn]: Parameter className is never used.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(544:17)[warn]: Public declaration 'enterTest' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(544:34)[warn]: Parameter test is never used.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(549:17)[warn]: Public declaration 'skip' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(549:29)[warn]: Parameter reason is never used.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(554:17)[warn]: Public declaration 'addFailure' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(554:35)[warn]: Parameter phase is never used.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(554:58)[warn]: Parameter exception is never used.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(559:17)[warn]: Public declaration 'addError' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(559:33)[warn]: Parameter phase is never used.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(559:50)[warn]: Parameter throwable is never used.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(564:17)[warn]: Public declaration 'exitTest' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(564:31)[warn]: Parameter success is never used.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(569:17)[warn]: Public declaration 'exit' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(574:17)[warn]: Public declaration 'write' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(593:7)[warn]: Public declaration 'XmlReporter' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(595:12)[warn]: Local imports should specify the symbols being imported to avoid hiding local symbols.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(601:17)[warn]: Public declaration 'enterClass' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(606:17)[warn]: Public declaration 'enterTest' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(614:17)[warn]: Public declaration 'skip' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(622:17)[warn]: Public declaration 'addFailure' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(625:16)[warn]: Variable message is never modified and could have been declared const or immutable.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(631:17)[warn]: Public declaration 'addError' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(634:16)[warn]: Variable message is never modified and could have been declared const or immutable.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(640:17)[warn]: Public declaration 'exitTest' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(640:31)[warn]: Parameter success is never used.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(642:16)[warn]: Variable elapsed is never modified and could have been declared const or immutable.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(651:17)[warn]: Public declaration 'exit' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(657:7)[warn]: Public declaration 'ReportReporter' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(659:12)[warn]: Local imports should specify the symbols being imported to avoid hiding local symbols.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(668:12)[warn]: Public declaration is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(677:17)[warn]: Public declaration 'enterClass' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(682:17)[warn]: Public declaration 'enterTest' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(691:17)[warn]: Public declaration 'skip' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(703:17)[warn]: Public declaration 'addFailure' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(709:20)[warn]: Variable message is never modified and could have been declared const or immutable.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(716:17)[warn]: Public declaration 'addError' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(722:20)[warn]: Variable message is never modified and could have been declared const or immutable.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(729:17)[warn]: Public declaration 'exitTest' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(729:31)[warn]: Parameter success is never used.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(731:16)[warn]: Variable elapsed is never modified and could have been declared const or immutable.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(736:17)[warn]: Public declaration 'exit' is undocumented.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(738:16)[warn]: Local imports should specify the symbols being imported to avoid hiding local symbols.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(753:17)[warn]: Variable "testClasses" has the same name as a variable defined on line 37.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(753:17)[warn]: Variable testClasses initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(804:39)[warn]: Parameter o is never used.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(809:26)[warn]: Parameter o is never used.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(809:36)[warn]: Parameter name is never used.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(814:38)[warn]: Parameter o is never used.
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\framework.d(847:16)[warn]: Variable block initializer is useless because it does not differ from the default value
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\ng\assertion.d(24:18)[warn]: Argument 1 is named 'expected', but this is the name of parameter 2
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\ng\assertion.d(24:28)[warn]: Argument 2 is named 'actual', but this is the name of parameter 1
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\ng\assertion.d(37:23)[warn]: Argument 1 is named 'expected', but this is the name of parameter 2
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\ng\assertion.d(37:23)[warn]: Argument 1 is named 'expected', but this is the name of parameter 2
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\ng\assertion.d(37:33)[warn]: Argument 2 is named 'actual', but this is the name of parameter 1
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\ng\assertion.d(37:33)[warn]: Argument 2 is named 'actual', but this is the name of parameter 1
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\ng\assertion.d(50:23)[warn]: Argument 1 is named 'expected', but this is the name of parameter 2
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\ng\assertion.d(50:23)[warn]: Argument 1 is named 'expected', but this is the name of parameter 2
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\ng\assertion.d(50:33)[warn]: Argument 2 is named 'actual', but this is the name of parameter 1
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\ng\assertion.d(50:33)[warn]: Argument 2 is named 'actual', but this is the name of parameter 1
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\ng\assertion.d(63:23)[warn]: Argument 1 is named 'expected', but this is the name of parameter 2
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\ng\assertion.d(63:33)[warn]: Argument 2 is named 'actual', but this is the name of parameter 1
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\ng\assertion.d(76:16)[warn]: Argument 1 is named 'expected', but this is the name of parameter 2
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\ng\assertion.d(76:26)[warn]: Argument 2 is named 'actual', but this is the name of parameter 1
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\ng\assertion.d(89:19)[warn]: Argument 1 is named 'expected', but this is the name of parameter 2
.\dependencies\d-unit-0.8.1\d-unit\src\dunit\ng\assertion.d(89:29)[warn]: Argument 2 is named 'actual', but this is the name of parameter 1
core.time.TickDuration
was deprecated in dmd 2.104.0 (see: dlang/dmd#15024), core.time.MonoTime
or core.time.Duration
should be used instead
https://dlang.org/phobos/core_time.html#.MonoTime
https://dlang.org/phobos/core_time.html#.Duration
src/dunit/framework.d(562,26): Deprecation: struct `core.time.TickDuration` is deprecated - TickDuration has been deprecated, please use Duration or MonoTime instead
src/dunit/framework.d(562,26): Deprecation: struct `core.time.TickDuration` is deprecated - TickDuration has been deprecated, please use Duration or MonoTime instead
src/dunit/framework.d(693,26): Deprecation: struct `core.time.TickDuration` is deprecated - TickDuration has been deprecated, please use Duration or MonoTime instead
src/dunit/framework.d(693,26): Deprecation: struct `core.time.TickDuration` is deprecated - TickDuration has been deprecated, please use Duration or MonoTime instead
src/dunit/framework.d(763,26): Deprecation: struct `core.time.TickDuration` is deprecated - TickDuration has been deprecated, please use Duration or MonoTime instead
src/dunit/framework.d(763,26): Deprecation: struct `core.time.TickDuration` is deprecated - TickDuration has been deprecated, please use Duration or MonoTime instead
By adding a @BeforeAll
method to my class (independent whether beforeAll method is marked as static or not) the application crashes with Program exited with code -11
on ubuntu 18.
import dunit;
class OperatorTests
{
mixin UnitTest;
@BeforeAll void beforeAll(){}
@Test void test1(){}
}
What do you think about supporting SkipIf
struct SkipIf
{
bool delegate() b; // or just "bool b" for only allowing compile time arguments?
string reason;
}
class GetDirectionalDerivativeTest
{
mixin UnitTest;
@Test
@SkipIf(() => !platform.among("win32", "win64"), "Platform not supported")
void test_get_directional_derivative()
{
}
}
Actually there is a DIP https://github.com/dlang/DIPs/blob/master/DIPs/DIP1033.md which would allow to write it like this:
@SkipIf(!platform.among("win32", "win64"), "Current platform not supported by this FMU")
It's probably something dumb I'm doing, so I'd appreciate any pointers - I'm fairly new to D and dub
. Here's my dub.json
:
{
"name": "dconfig",
"authors": [
"Vinay Sajip"
],
"description": "A test.",
"dependencies": {
"d-unit": "~>0.9.0"
}
}
and here's my test code:
module tests;
import dunit;
class MyFirstTest {
mixin UnitTest;
@Test
public void shouldFail()
{
string expected = "bar";
string actual = "baz";
assertEquals(expected, actual);
}
}
When I run dub test
, I get:
Generating test runner configuration 'dconfig-test-library' for 'library' (library).
Performing "unittest" build using /usr/bin/dmd for x86_64.
d-unit 0.9.0: target for configuration "library" is up to date.
dconfig ~master: building configuration "dconfig-test-library"...
Linking...
To force a rebuild of up-to-date targets, run again with --force.
Running ./dconfig-test-library
All unit tests have been run successfully.
But nothing seems to run, since no failure is printed. The dconfig-test-library
certainly seems to contain the symbols for MyFirstTest
and shouldFail
, so why would the test not be run?
The D version is DMD64 D Compiler v2.082.0
, running on Ubuntu 16.04.
By the way, your example.d
shows a mixin Main;
, but I've omitted that since it doesn't seem to be needed to bring a main
in. In fact, adding it causes a build failure due to Error: only one main allowed.
src/dunit/assertion.d seems to have a problem on Mac OS with this unit test:
unittest
{
assertEventually({ static count = 0; return ++count > 23; });
auto exception = expectThrows!AssertException(assertEventually({ return false; }));
assertEquals("timed out", exception.msg);
}
Building with either dmd or ldc on macos-latest (github runner) gets the following output:
Run dub test --coverage
Fetching undead 1.1.8 (getting selected version)
Starting Performing "unittest-cov" build using /Users/runner/hostedtoolcache/dc/dmd-2.10[6](https://github.com/SingingBush/dunit/actions/runs/7184674452/job/19566285169#step:5:7).0/x64/dmd2/osx/bin/dmd for x[8](https://github.com/SingingBush/dunit/actions/runs/7184674452/job/19566285169#step:5:9)6_64.
Building undead 1.1.8: building configuration [library]
Building d-unit ~ci/github_action: building configuration [unittest]
Linking d-unit
Running d-unit
F.
There was 1 failure:
1) dunit.assertion.unittest
src/dunit/assertion.d:688 dunit.assertion.AssertException: timed out
Tests run: 2, Failures: 1, Errors: 0, Skips: 0
NOT OK
Error Program exited with code 2
Error: Process completed with exit code 2.
The following sample has 1 test class with 1 test method but the output shows 2 tests in console and also in the xml report.
dub test --skip-registry=all -- --report=dunit.xml
..
Tests run: 2, Failures: 0, Errors: 0, Skips: 0
OK
dunit.xml
<testsuites>
<testsuite name="dunit">
<testcase name="unittest" time="0.000" classname="app" />
<testcase name="checkAnswer" time="0.000" classname="tests.tests.TestCase" />
</testsuite>
</testsuites>
While passing a file path via console argument "report" there is an exception thrown if the folder does not exist.
dub test -- --report results/junit.xml
Could you create the folder(s) instead of throwing an exception?
d-unit has a dependency to unit-threaded this causes issues. I created a XMake build infrastructure. There is a golden rule, that during the build, the internet must not be accessed. Therefore I fetched d-unit upfront and placed it within my dub package folder. Within dub.json I specified the dependency to d-unit via the "path" attribute.
While executing dub build, there is now an error thrown
Could not find a valid dependency tree configuration: Package d-unit contains invalid dependency
unit-threaded (no version candidates)
Although I do not use this configuration, dub will check the dependency and will fail the build.
Could you check whether you can enabled fluent assertions without having a dependency to unit-threaded?
d-unit is such an important library, it would be nice if it is completely independent.
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?
I ran the example.d, the output style of tests are something I would like to use for my code. However, reading example.d content, it is not clear to me what is the real code and what is the test code. And more practically, how do I migrate from the code using D built-in unittest to dunit
.
For example, consider myDbuiltinTest.d:
import std.string: toLower;
string strToLower(string s){
string ret;
foreach(c; s) ret ~= toLower(c);
return ret;
}
unittest{
writeln("Test strToLower);
assert("lower" == strToLower("LoWer"));
}
unittest{
writeln("Test strToLower with unicode);
assert(" lower2 ü" == strToLower(" LoWer2 Å"));
}
My questions:
dunit
in this case?.d
files and execute them individually?I created a dub project using "dub init dtest2" and specified the dependency to "d-unit".
dub.json looks like this:
{
"name": "dtest2",
"dependencies": {
"d-unit": "~>0.8.1"
}
}
It is quite hard for a beginner maybe much to hard to get the unittest running using command "dub test".
I have a app.d file with this content:
version (unittest)
{
import dunit;
mixin Main;
}
else
{
void main()
{
import std.stdio;
writeln("Edit source/app.d to start your project.");
}
}
and a test1.d file with this content:
import dunit;
class Test
{
mixin UnitTest;
@Test void myTest() { assertEquals("foo", "bar"); }
}
The result of running "dub test" is: All unit tests have been run successfully.
By removing the "mixin Main" in app.d and adding it to test1.d
// app.d
version (unittest){}
else
{
void main()
{
import std.stdio;
writeln("Edit source/app.d to start your project.");
}
}
// test1.d
import dunit;
version (unittest)
{
import dunit;
mixin Main;
}
class Test
{
mixin UnitTest;
@Test
void myTest() { assertEquals("foo", "bar"); }
}
there is now an error returned while running dub test:
....\AppData\Roaming\dub\packages\d-unit-0.8.1\d-unit\src\dunit\framework.d(47,9): Error: only one main/WinMain/DllMain allowed. Previously found main at ....\AppData\Local\Temp\dub_test_root-68e76de3-85a8-4cc2-baba-ce3d55b37483.d(9,12)
dmd failed with exit code 1.
My gut feeling is, dub is causing this issue because the application is detected as "library" anf therefore a default test runner is generated...
Maybe you can add a dub example which shows the correct way or you can enhance the readme. For an unexperienced developer there is a high level of frustration until d-unit is working correctly within dub.
(To get it working I had to add a debug and unittest configuration with specifying targetType and setting the mainSourceFile..., but I am not sure whether this is the correct way or it is a workaround for a dub bug)
I have simple test with mixin Main;
in the end like suggested:
module test;
import dunit.ng;
class Test {
mixin UnitTest;
@Test
void assertSuccess() {
assertEquals(1, 1);
}
@Test
void assertFailure() {
assertEquals(1, 2);
}
}
mixin Main;
dub test
fails with:
C:\Users\vladi\AppData\Local\Temp\dub_test_root_c931562a_8985_4af8_b4db_eada183d4cd7.d(12,12): Error: only one `main`, `WinMain`, or `DllMain` allowed. Previously found `main` at C:\Users\vladi\AppData\Local\dub\packages\d-unit-0.9.3\d-unit\src\dunit\framework.d(47,9)
C:\Users\vladi\AppData\Local\Temp\dub_test_root_c931562a_8985_4af8_b4db_eada183d4cd7.d(12,12): Warning: skipping definition of function `D main` due to previous definition for the same mangled name: _Dmain
C:\tools\ldc\bin\..\import\core\internal\entrypoint.d(29,17): Warning: skipping definition of function `dub_test_root._d_cmain!().wmain` due to previous definition for the same mangled name: wmain
ldc2 failed with exit code 1.
Could you please replace the deprecated approxEqual
function with isClose
?
Thanks a lot.
It should be possible to define Tags on Test class level. Theses tags should be inherited to all tests of the class.
Pull request #20
while compiling a project, I got this message:
../../../.dub/packages/d-unit-0.9.2/d-unit/src/dunit/framework.d(614,12): Deprecation: module std.xml is deprecated - Will be removed from Phobos in 2.101.0. If you still need it, go to https://github.com/DigitalMars/undeaD ../../../.dub/packages/d-unit-0.9.2/d-unit/src/dunit/framework.d(681,12): Deprecation: module std.xml is deprecated - Will be removed from Phobos in 2.101.0. If you still need it, go to https://github.com/DigitalMars/undeaD
Newest dmd version is throwing warnings due to the usage of the body
keyword. Could you have a look?
Thanks.
Line 242 in 2d1a467
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.