Skip to content
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

Code refactoring for extension testing #10529

Merged
merged 15 commits into from
Jun 16, 2020
Merged

Code refactoring for extension testing #10529

merged 15 commits into from
Jun 16, 2020

Conversation

aasimkhan30
Copy link
Contributor

@aasimkhan30 aasimkhan30 commented May 20, 2020

I would like some inputs for more code refactoring. My end goal is to make the extension more unit testable by making it easy to mock the classes.

@coveralls
Copy link

coveralls commented May 20, 2020

Coverage Status

Coverage increased (+0.4%) to 34.904% when pulling e524eb5 on aasim/import/testing into 434d017 on main.


export class ApiWrapper {

public createOutputChannel(name: string): vscode.OutputChannel {
Copy link
Contributor

Choose a reason for hiding this comment

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

Whats the goal in introducing this? From what I can tell you are just adding integration tests, which makes this api wrapper unnecessary.

Copy link
Contributor Author

@aasimkhan30 aasimkhan30 May 22, 2020

Choose a reason for hiding this comment

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

The naming is kind of weird in the test script but those are unit tests and not integration tests. I've created the wrapper just to mock those apis. Let me know if I those are integration tests.

Copy link
Contributor

@anthonydresser anthonydresser May 22, 2020

Choose a reason for hiding this comment

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

What i'm saying is you don't need to mock them. they aren't true unit tests in that they run in their own context. Those tests get run in a ADS environment, vscode, ads, all that will exist.

Copy link
Contributor

Choose a reason for hiding this comment

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

@anthonydresser I think the plan is to test this feature without an active SQL connection, so I think some of the API calls will be mocked.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's a consistency thing too - just keeping all vscode/azdata calls through the api wrapper so that if we do care about mocking them out if we can. And adding them here doesn't really have any noticeable impact.

Copy link
Contributor

@aaomidi aaomidi left a comment

Choose a reason for hiding this comment

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

From a quick glance it seems fine, make sure to do e2e testing of this manually and check to see if the scenarios work as expected.

extensions/import/src/test/import.test.ts Outdated Show resolved Hide resolved
extensions/import/src/test/index.ts Show resolved Hide resolved
extensions/import/src/services/telemetry.ts Outdated Show resolved Hide resolved
@adsbot adsbot bot added the Stale PR label Jun 9, 2020
@adsbot adsbot bot removed the Stale PR label Jun 12, 2020
@aaomidi
Copy link
Contributor

aaomidi commented Jun 12, 2020

Can you @ me for a review when the changes have been finalized?

@aasimkhan30
Copy link
Contributor Author

@aaomidi I won't be making any more changes to this PR. I have written some additional tests but that's for another PR

@kburtram kburtram changed the base branch from master to main June 15, 2020 06:21
extensions/import/coverageConfig.json Outdated Show resolved Hide resolved
@aasimkhan30 aasimkhan30 merged commit f725ee9 into main Jun 16, 2020
@aasimkhan30 aasimkhan30 deleted the aasim/import/testing branch June 16, 2020 20:24
ktech99 pushed a commit that referenced this pull request Aug 23, 2020
* Setting up tests on import extension

* -Added API wrappers for all the azdata and vscode APIs to make them easily mockable
-Added some unit tests for the import extension
-Some code logic separations

* -added code report for the import extension in ci

* Did some more code refractoring

* -Added json report generation

* updated vscodetestcoverage to latest version in import extension.

* -remove duplicate codecoverageConfig.json
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.

5 participants