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
Even though metals-vscode has many advanced features (such as checking for updates, installing java, showing release notes, etc.), there are quite a small number of unit/integration tests.
Therefore, when we update the features of metals-vscode, we usually "test" the extension by hand. However, testing by hand leaves a lot of anxiety for release. (What if some features are broken without notice?)
I propose adding some unit tests to the extension to remove the anxieties. (It would be best if we could test all the features with integration tests, but it requires too much, let's start with unit testing).
Which features to unit test?
In unit tests, we should focus on the logic that can be independent of vscode APIs.
check for updates on the Metals server
needCheckForUpdates
validateCurrentVersion
releaseNoteProvider
installJavaAction
I guess other features can be tested by integration tests.
The vscode-test package allows you to run integration tests where you launch the tests through vscode and a instance of vscode opens up. But if I want to do normal unit tests against code that has even a single reference to vscode I am not able to do so due to microsoft/vscode#6586.
to run unit tests, we should extract the logic that doesn't depend on vscode API by abstracting out the dependencies.
In order to do this, I would propose adding some layers to the project structures.
application layer: this layer is basically referred from extension.ts
can access vscode APIs (executing command, setting up repositorys for service layer using VSCode APIs.
service layer: this layer contains the business logic that doesn't rely on vscode APIs, we will unit test against this layer.
repository layer: this layer contains the logic that
access to vscode APIs (such as reading and updating configurations)
Describe the problem
Even though
metals-vscode
has many advanced features (such as checking for updates, installing java, showing release notes, etc.), there are quite a small number of unit/integration tests.Therefore, when we update the features of
metals-vscode
, we usually "test" the extension by hand. However, testing by hand leaves a lot of anxiety for release. (What if some features are broken without notice?)I propose adding some unit tests to the extension to remove the anxieties. (It would be best if we could test all the features with integration tests, but it requires too much, let's start with unit testing).
Which features to unit test?
In unit tests, we should focus on the logic that can be independent of vscode APIs.
needCheckForUpdates
validateCurrentVersion
releaseNoteProvider
installJavaAction
I guess other features can be tested by integration tests.
For writing unit tests
As described in microsoft/vscode#82471
to run unit tests, we should extract the logic that doesn't depend on vscode API by abstracting out the dependencies.
In order to do this, I would propose adding some layers to the project structures.
application layer
: this layer is basically referred fromextension.ts
repository
s for service layer using VSCode APIs.service layer
: this layer contains the business logic that doesn't rely on vscode APIs, we will unit test against this layer.repository layer
: this layer contains the logic thatHere's a POC implementation for unit testing
needCheckForUpdate
tanishiking#82Additional context
Search terms
unit test
The text was updated successfully, but these errors were encountered: