InterSystems Testing Manager
This extension uses VS Code's Testing API to discover, run and debug unit test classes built with the %UnitTest testing framework of the InterSystems IRIS platforms, plus Caché-based predecessors supporting the It augments the ObjectScript, InterSystems Language Server and Server Manager extensions, which are elements of the InterSystems ObjectScript Extension Pack. Classes extending InterSystems Testing Manager works with both of the source code location paradigms supported by the ObjectScript extension. Your unit test classes can either be mastered in VS Code's local filesystem (the 'client-side editing' paradigm) or in a server namespace (the 'server-side editing' paradigm). In both cases the actual test runs occur in a server namespace. Client-side editing workspace Server-side editing workspace When used alongside Test Coverage Tool this extension presents coverage inside VS Code: Coverage example showing coverage of Test Coverage Tool's own unit tests In the above screenshot the Test Coverage view has been dragged to the secondary sidebar. Displaying which code lines your tests cover aids the improvement of those tests. The greater the percentage of code lines covered by testing, the more likely your tests will detect regressions. Below is an example from the InterSystems Package Manager repository. Two test classes ran code in the %IPM.Repo.Definition class, but neither of them covered line 88 in the screenshot below: Tests failed to cover line 88 The optional Test Coverage Toolbar at the top of the class's editor and the coverage decorations in the Explorer tree combine to promote good testing habits. In order to support topologies in which client-side-managed test classes have to be run in the namespace of a remote server, this extension uses the Server Preparations
Workspace PreparationsFor a workspace using client-side editing, test classes are by default sought in
Running TestsVS Code provides several different ways to run tests. In the Test Explorer view expand the first root folder, which is captioned 'Local Tests' or 'Server Tests' depending on which paradigm your workspace uses. A subfolder is shown for each root folder of your workspace, which may be a multi-root one. Within this you are shown the test classes. The 'Local Tests' tree uses a hierarchical structure with one subfolder per segment of the package name. The 'Server Tests' tree uses a flat structure. At the level of an individual test class the final expansion shows a leaf for each Hovering over any level of a tests tree will reveal action buttons that run all the tests from this level down. The 'Run Test' button does so without stopping at any breakpoints, in contrast to the 'Debug Test' button. At class or method level a 'Go to Test' button opens the class code and positions the cursor appropriately. At higher levels this button navigates to Explorer View. When a test class is open in an editor tab it displays icons in the gutter at the top of the class and at the start of each test method. These show the outcome of the most recent run, if any, and can be clicked to perform testing operations. The Debugging TestsAfter opening a test class, click in the gutter to set a VS Code breakpoint in the normal manner. Then launch the test-run with the Debug option on the context menu of the testing icons in the gutter. Obtaining Test Coverage InformationUse the 'Run with Coverage' option to submit your tests to Test Coverage Tool. When the run finishes the 'TEST COVERAGE' view will appear, usually below the 'TEST EXPLORER'. Use this to discover what proportion of executable code lines were covered by the most recent coverage run. Open sources to see color markers on line numbers showing covered (green) and not covered (red) lines. Learn more in the VS Code documentation. Recent Testing HistoryThe %UnitTest framework persists results of runs in server-side tables. The 'Recent History' root folder lets you explore the most recent ten sets of results for each server and namespace the workspace uses. Hovering on a run's folder reveals an action button which launches %UnitTest's own results browser in an external web browser. Known LimitationsThis extension has some known quirks and limitations:
FeedbackInitial development of this extension by George James Software was sponsored by InterSystems. Please create issues at https://github.com/intersystems-community/intersystems-testingmanager/issues to report bugs, questions or suggestions for improvement. We also invite you to post about this extension at https://community.intersystems.com |