RDCore.UnitTesting
Ce document est disponible en français

V I V A T ❤️ C U C U M I S ™
Note
RDCore.UnitTesting is an alpha prerelease (v0.1.0-alpha), for rdc v0.2.10-alpha or later. rdc test <workspace> runs a workspace's tests from the command line; the editor runs none.
What it is
RDCore.UnitTesting is the unit testing extension of RDCore. Comment annotations make a standard module a test module and its procedures its tests, with the procedures that set up and clean up after them.
'@TestModule
Option Explicit
'@TestMethod("Arithmetic")
Public Sub AddsTwoNumbers()
Assert.AreEqual 3, 1 + 2
End Sub
The annotations are comments to VBA, so the module remains a VBA standard module. Assert is the module of the RDTest library, which the project references ("References": [ { "Name": "RDTest" } ] in its .rdproj). The runner calls the tests and the setup and cleanup procedures from outside their module, so they are Public.
rdc test <workspace> [--report junit <path>]
rdc test writes a line for each test run, then Passed: n, Failed: n, Skipped: n, where Skipped counts the ignored and the inconclusive tests. It exits with 0 when no test failed, 1 when one did, and 2 for arguments it does not take. --report junit also writes the results as a JUnit XML file.
The annotations
| Annotation | On | Meaning |
|---|---|---|
'@TestModule |
The module | The module is a test module: its tests run in a session of their own. |
'@TestMethod |
A Sub |
The procedure is a test. Its optional argument is its category. |
'@ModuleInitialize |
A Sub |
Runs once, before the module's first test. |
'@ModuleCleanup |
A Sub |
Runs once, after the module's last test. |
'@TestInitialize |
A Sub |
Runs before each test of the module. |
'@TestCleanup |
A Sub |
Runs after each test of the module, whatever the test's outcome. |
'@IgnoreTest |
A test | The test does not run: its outcome is Ignored. |
'@TestCase |
A test | A row of arguments: the test runs once for each row. |
'@ExpectedError |
A test | The run-time error the test passes by raising, such as VBR00013. |
What works
| Part | Status |
|---|---|
| The extension, started by the platform | Works. |
| The annotations: completion and descriptions in the editor | Works in an RDCore platform that loads the extension. |
| Finding tests, and the diagnostics of a test that cannot run | Works in an RDCore platform that loads the extension. |
Running tests with rdc test: the run order, '@TestCase rows, '@ExpectedError, and the JUnit report |
Works in an RDCore platform that loads the extension. |
Assert, in the RDTest library: its 13 checks, which compare as = and Is do in the calling module |
Works. |
| Running tests from the editor | Not implemented. |
ACCUEIL • HOME | RDCore | 🌐 rubberduckvba.ca