Skip to content

Add support for running and debugging unit tests #1269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 26, 2024

Conversation

isc-bsaviano
Copy link
Contributor

@isc-bsaviano isc-bsaviano commented Nov 2, 2023

This PR can be tested with the latest 2023.3 preview kit (build 245). The documentation has not been written yet, but here are some bullet points about how this new feature works that I have passed to our docs team:

  • The extension supports running tests in client-side or server-side workspace folders.
  • For server-side workspace folders, all test classes in the folder are shown in the Testing view. A root in the Testing view is created for each server-side workspace folder.
  • For client-side workspace folders, you must configure the objectscript.unitTest.relativeTestRoots setting to tell the extension where your tests are located. A root in the Testing view is created for each element in this array.
  • When running server-sider test classes, the versions of the classes stored on the server are run, and the tests are re-compiled before they are run.
  • When running client-side tests, the extension loads all test classes from your local workspace folder onto the server, overwriting any versions that may have existed. The extension also loads any autoload files. The autoload feature behavior can be configured by the objectscript.unitTest.autoload settings. All files in autoload folders that are in the tree of tests to run, up to the objectscript.unitTest.relativeTestRoots value for that Testing root, will be loaded on the server as well. Any documents that were created on the server by the loading will be deleted after the test run is complete. The autoload feature supports loading .cls, .mac, .int and .inc files, as well as legacy XML export files.
  • All client-side test classes and autoload files are sent to the server in a single REST request. This means that you could theoretically surpass the size limit for POST requests set by your web server. I consider this unlikely since this was designed for running small suites of tests during development, and not for loading large suites outside of development.
  • The value of ^UnitTestRoot is not modified during the test run, so whatever value it is currently set to will be used. This is important to note if your tests use that value to load files from the file system during the run.
  • The extension only supports running tests that are in files with the .cls extension. If your tests are in legacy XML export format, you must convert them to .cls files to run them in a client-side workspace folder. If you use server-side editing, you can use the WebSocket Terminal to run the DebugLoadTestSuite() method in %UnitTest.Manager to load the tests into your server.
  • Note: The Manager.CurrentDir property will likely not be set correctly. The Atelier endpoints always run tests with ^UnitTestRoot as the directory, so if your tests rely on this property to load files from the file system based on the test suite directory, that won't work.
  • Fixes Update link to Compile flags documentation #1271

Copy link
Contributor

@gjsjohnmurray gjsjohnmurray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@isc-bsaviano I don't have bandwidth at the moment to test this, but I've reviewed the changes and code-wise they look fine. Let me know if you'd like it approved so you can merge it now 2023.3 has shipped.

@isc-bsaviano
Copy link
Contributor Author

That ok @gjsjohnmurray, I'll wait for your input since this is a big new feature.

@isc-bsaviano
Copy link
Contributor Author

@gjsjohnmurray Now that it's the new year I'd appreciate you taking a look at this when you have some time. I'll update this branch from master when your search PR is merged.

@isc-bsaviano isc-bsaviano merged commit 0a4bb37 into intersystems-community:master Jan 26, 2024
@isc-bsaviano isc-bsaviano deleted the unit-tests branch January 26, 2024 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update link to Compile flags documentation
3 participants