You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That wasn't around when this extension was originally built, so the OPA test commands simply call out to OPA and display the output as provided. Using the Test API provides a nicer integration though, and allows things like running single tests or all tests in a file right from the editor view, as seen here from my late night POC:
There are however some minor incompatibilities in how OPA runs tests vs. how IDEs like VS Code runs them:
IDE test runners work on the level of files or single tests — the OPA test runner will just run any tests it finds
There’s an option to --run only tests matching a filter, but there’s no guarantee that it’ll match only the test the user clicked as there could be many tests of the same name in the loaded workspace
One workaround, sort of, could be to actually run all tests always, but only display the result from the file or test the user asked for. This is doable as the JSON test output prints the file + test name for each result. For the single test case, we could do a combo of --run plus filter the result to only match the file where it’s clicked.
This would of course mean that we'd often be running a bunch of tests that nobody asked for, but since test execution in OPA is normally very fast, this will likely not be noticeable in anything but huge projects.
Long term solution would be to update the OPA test runner to allow loading all files, but only run tests from files that are explicitly provided.
The text was updated successfully, but these errors were encountered:
That wasn't around when this extension was originally built, so the OPA test commands simply call out to OPA and display the output as provided. Using the Test API provides a nicer integration though, and allows things like running single tests or all tests in a file right from the editor view, as seen here from my late night POC:
Since v1.88, there's also a native API for test coverage.
There are however some minor incompatibilities in how OPA runs tests vs. how IDEs like VS Code runs them:
--run
only tests matching a filter, but there’s no guarantee that it’ll match only the test the user clicked as there could be many tests of the same name in the loaded workspaceOne workaround, sort of, could be to actually run all tests always, but only display the result from the file or test the user asked for. This is doable as the JSON test output prints the file + test name for each result. For the single test case, we could do a combo of
--run
plus filter the result to only match the file where it’s clicked.This would of course mean that we'd often be running a bunch of tests that nobody asked for, but since test execution in OPA is normally very fast, this will likely not be noticeable in anything but huge projects.
Long term solution would be to update the OPA test runner to allow loading all files, but only run tests from files that are explicitly provided.
The text was updated successfully, but these errors were encountered: