Skip to content

Show diagnostics for failed/skipped tests run with pytest - #3303

Merged
Don Jayamanne (DonJayamanne) merged 15 commits into
microsoft:masterfrom
SalmonMode:pytest-connect-problems
Jan 7, 2019
Merged

Don Jayamanne (DonJayamanne) merged 15 commits into
microsoft:masterfrom
SalmonMode:pytest-connect-problems

Conversation

@SalmonMode

@SalmonMode Chris NeJame (SalmonMode) commented Nov 11, 2018 •

Copy link
Copy Markdown

For #120

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR)
  • Title summarizes what is changing
  • Has a news entry file (remember to thank yourself!)
  • Unit tests & system/integration tests are added/updated
  • Test plan is updated as appropriate
  • package-lock.json has been regenerated by running npm install (if dependencies have changed)

Some notes:

I have it adding a DiagnosticRelatedInformation for each level of the traceback for tests with problems. The order of them should be dependent on the actual order of the traceback, but I believe the Problems pane doesn't preserve their order for some reason.

I also have it making a Diagnostic object for skipped tests, but they only have a severity of Information.

The message for the Diagnostic object is the message property provided by by the TestFunction, prefixed with a summary of the test's status (i.e. Error/Fail/Skipped).

In the event that a failed test was brought into a class by a class that was imported from another module, then the Diagnostic will point at the class that actually had the test which ran. This is to keep the Diagnostic pointing at something with meaningful context, so you can know what test files are actually experiencing failed tests. It even works for nested classes and nested classes inside class that are imported! It just tries to follow the chain as far down as it can within the file.

I also made sure that if a test has a Diagnostic due to a failure/error/skip, and the test is run again, the Diagnostic will be wiped out and then, if the test still has an issue, a new Diagnostic is added back in showing the current status and traceback of the test. This ensures that the Diagnostic is always up to date, and goes away once the test is passing.

@msftclas

Microsoft Contribution License Agreements (msftclas) commented Nov 11, 2018 •

Copy link
Copy Markdown

CLA assistant check
All CLA requirements met.

@SalmonMode

Copy link
Copy Markdown
Author

Finally figured out that when asking for the fsPath property of a Uri object on Windows, it makes the drive letter lowercase, which was messing with some of my comparisons.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I've started testing this and here are some issues i've come across:

  • Once a broken test is fixed, the problems do not go away, they are still displayed in the problems window.
  • I quite like the way you have displayed the errors in the problems window.
    Please could you try to ensure they are displayed in one line as opposed to having line breaks in there. (see here where there seems to be some line breaks) #120 (comment)

FYI:

  • I merged the master with your changes and #3770

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Over all a great job, minor fixes/changes.
Looking forward to merging this PR.

Comment thread src/client/unittests/common/managers/baseTestManager.ts Outdated
Comment thread src/client/unittests/common/managers/baseTestManager.ts Outdated
Comment thread src/client/unittests/common/services/unitTestDiagnosticService.ts Outdated
Comment thread src/client/unittests/common/services/unitTestDiagnosticService.ts Outdated
Comment thread src/client/unittests/pytest/main.ts Outdated
@SalmonMode

Chris NeJame (SalmonMode) commented Dec 27, 2018 •

Copy link
Copy Markdown
Author

Thanks a ton for the feedback! I really appreciate it 😃

Once a broken test is fixed, the problems do not go away, they are still displayed in the problems window

Thanks for the examples screenshots in #120! The parametrization stuff tipped me off. Turns out, it was because the name of the test itself is technically changing because the params changed. So I added a check in the stripStaleDiagnosticMessages function to remove any diagnostics that no longer had any associated tests.

I quite like the way you have displayed the errors in the problems window.
Please could you try to ensure they are displayed in one line as opposed to having line breaks in there. (see here where there seems to be some line breaks) #120 (comment)

Thanks! I wasn't sure how people would feel about that, but I wanted something convenient to jump to each point in the stack trace. I ended up just stripping out anything coming after the first new line, because pytest can dive pretty deep when it describes what variables were what, and I wasn't sure where else I could put them.

I was hoping there would be some title text for the diagnostic I could leave them in, but it doesn't look like VS Code supports that yet. Maybe I should make a feature request for that 🤔

I merged the master with your changes and #3770

I wasn't sure what to do with this info, but I appreciate it! 😄 Should I rebase there or something for this PR?

Chris NeJame and others added 2 commits December 27, 2018 10:48
…ssages, fixed issue with diagnostics not going away due to their name changing, and cleaned up code.
@codecov

codecov Bot commented Jan 4, 2019

Copy link
Copy Markdown

Codecov Report

Merging #3303 into master will increase coverage by 1%.
The diff coverage is 98%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #3303    +/-   ##
=======================================
+ Coverage      79%     79%    +1%     
=======================================
  Files         400     402     +2     
  Lines       18247   18478   +231     
  Branches     2944    2968    +24     
=======================================
+ Hits        14280   14498   +218     
- Misses       3964    3977    +13     
  Partials        3       3
Flag Coverage Δ
#Linux 68% <98%> (+1%) ⬆️
#Windows 68% <98%> (+1%) ⬆️
#macOS 68% <98%> (+1%) ⬆️
Impacted Files Coverage Δ
src/client/unittests/serviceRegistry.ts 98% <100%> (+1%) ⬆️
src/client/unittests/types.ts 100% <100%> (ø) ⬆️
src/client/common/utils/localize.ts 97% <100%> (+1%) ⬆️
...tests/common/services/unitTestDiagnosticService.ts 100% <100%> (ø)
src/client/unittests/pytest/main.ts 94% <100%> (+2%) ⬆️
src/client/unittests/common/xUnitParser.ts 86% <100%> (-1%) ⬇️
src/client/unittests/common/types.ts 100% <100%> (ø) ⬆️
...lient/unittests/common/managers/baseTestManager.ts 83% <94%> (+4%) ⬆️
...nt/unittests/pytest/services/testMessageService.ts 97% <97%> (ø)
.../client/common/net/socket/socketCallbackHandler.ts 81% <0%> (-2%) ⬇️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ebe8e5a...9d4fd7a. Read the comment docs.

1 similar comment
@codecov

codecov Bot commented Jan 4, 2019

Copy link
Copy Markdown

Codecov Report

Merging #3303 into master will increase coverage by 1%.
The diff coverage is 98%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #3303    +/-   ##
=======================================
+ Coverage      79%     79%    +1%     
=======================================
  Files         400     402     +2     
  Lines       18247   18478   +231     
  Branches     2944    2968    +24     
=======================================
+ Hits        14280   14498   +218     
- Misses       3964    3977    +13     
  Partials        3       3
Flag Coverage Δ
#Linux 68% <98%> (+1%) ⬆️
#Windows 68% <98%> (+1%) ⬆️
#macOS 68% <98%> (+1%) ⬆️
Impacted Files Coverage Δ
src/client/unittests/serviceRegistry.ts 98% <100%> (+1%) ⬆️
src/client/unittests/types.ts 100% <100%> (ø) ⬆️
src/client/common/utils/localize.ts 97% <100%> (+1%) ⬆️
...tests/common/services/unitTestDiagnosticService.ts 100% <100%> (ø)
src/client/unittests/pytest/main.ts 94% <100%> (+2%) ⬆️
src/client/unittests/common/xUnitParser.ts 86% <100%> (-1%) ⬇️
src/client/unittests/common/types.ts 100% <100%> (ø) ⬆️
...lient/unittests/common/managers/baseTestManager.ts 83% <94%> (+4%) ⬆️
...nt/unittests/pytest/services/testMessageService.ts 97% <97%> (ø)
.../client/common/net/socket/socketCallbackHandler.ts 81% <0%> (-2%) ⬇️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ebe8e5a...9d4fd7a. Read the comment docs.

@DonJayamanne
Don Jayamanne (DonJayamanne) merged commit 692365e into microsoft:master Jan 7, 2019
@lock lock Bot locked as resolved and limited conversation to collaborators Jul 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants