-
Notifications
You must be signed in to change notification settings - Fork 163
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
Fix Importing Test Results Failure for MsTest for Ignored Scenarios #378
Conversation
nnanoob
commented
Sep 30, 2016
- fix null featureTreeNode in ApplyTestResultsToFeature
- handle null value for GetExampleResults and defaulted to TestResult.Inconclusive
+ handle null value for GetExampleResults and defaulted to TestResult.Inconclusive
{ | ||
var featureTreeNode = node as FeatureNode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change has nothing to do with the fix, has it? Please do me a favour and resist giving in to ReSharper's style suggestions while doing a fix. I will be happy to review this kind of changes but please send them in a separate pull request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change is actually required because the original code, featureTreeNode = node as FeatureNode will returns null and no test results will be imported
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I stand corrected.
Wouldn't it be simpler then to use the OfType extension method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored to use OfType. Was copy pasting sample code from ImageNode earlier. But I didn't refactored those.
@@ -137,6 +137,10 @@ public override TestResult GetExampleResult(ScenarioOutline scenario, string[] e | |||
var scenarioElements = this.GetScenariosForScenarioOutline(scenario); | |||
|
|||
var theScenario = this.GetScenarioThatMatchesTheExampleValues(scenario, exampleValues, scenarioElements); | |||
if (theScenario == null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this fix. I'm following a test-first policy in Pickles, so please provide some tests for this case. It is worth checking out the other test result providers because the same problem may be lurking there.
See CONTRIBUTING.md for information on how to contribute code to the test result providers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added test for MsTest under WhenParsingMsTestResultsFileWithIgnoredExample.cs
{ | ||
var featureTreeNode = node as FeatureNode; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I stand corrected.
Wouldn't it be simpler then to use the OfType extension method?
public class WhenParsingMsTestResultsFileWithIgnoredExample : StandardTestSuite<MsTestResults> | ||
{ | ||
public WhenParsingMsTestResultsFileWithIgnoredExample() | ||
: base("MsTest." + "results-example-mstest-ignoredexample.trx") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simply for my understanding: why did you chose ignored examples. Is there anything magic about ignored in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. The fix was in MSTest GetExampleResult which deal with ScenarioOutline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that the fix is about Scenario Outlines :-) What I wanted to know was why are you using an Ignored example? Would it also work if you have "normal" examples?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original code will work fine if all are "normal" examples, but exception will be thrown if one of the examples are "ignored". A sample SpecFlow scenario below will results in exception
Scenario Outline: An example outline
Given I have an example
Examples:
| TestCase |
| 1 |
@ignore
Examples:
| TestCase |
| 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would happen if we use this scenario outline:
Given I have an example
Examples:
| TestCase |
| 1 |
And then search for the example from row 2 - wouldn't that fail in just the same way in the original code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry. kinda lost you here. But I'll try to answer :)
In the new code, the search on the row 2 (ignored) will still fail, but GetExampleResult method will handle it gracefully (check on null) and treat it as Inconclusive so that the whole cycle can be completed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try to explain what I'm after in a different way.
I find the use of "ignored" here confusing. I think you can achieve the same test if you simply search for a example result that does not exist. Maybe I'm missing something. What value do you get from talking about ignored examples instead of normal examples?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha. I got you now. I'm just writing the test from the perspective of how a real life scenario will be (where you will be having an Example which is ignored and which resulted in the example results not to exists. The example results does not go missing by itself unless it was ignored or someone updated the .feature and then trying to generate the doc (with .trx that is ran with older .feature). I believe the first scenario is more likely to happen, thus that explain the test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get it now. You're right, it is more likely that a result is not found because the scenario was ignored that that it is not found because the scenario was changed after the tests were run.
* Delete CNAME as advised by github support * Create CNAME * Get rid of ngenerics (#370) * Use Tree instead of NGenerics.GeneralTree * Use visitor instead of ActionVisitor * Rename Visitor to Traversor * Remove reference to unused NGenerics library * Fix whitespace * Remove NGenerics from nuspecs and build scripts * Get rid of traversor * Compatibility with nunit.console 3.4 and nunit.framework 2.6 (#369) * Compatibility with nunit.console 3.4 and nunit.framework 2.6 * Added example output file and test for nunit 2 tests ran with nunit 3 runner. * Add "NUnit 2 tests run by NUnit 3" to test harness (#371) * Move generation and commit of output to DeployArtifacts (#372) * Added test for sorting when generating word docs (#373) * Added test for sorting when generating word docs * Use stream overloads of WordprocessingDocument * Improve tree (#374) * Add test about sorting * Make it compile * Make it pass * Check for null in constructor * Add test about null names in iteration * Factory method for creating trees * Check for null tree when adding * Add test for null node * Release 2.8.3 (#377) * Release 2.6.3 (#347) * Enhancement to support Unix path! (#344) I'm not sure you already got a try or a feedback about it but actually pickles run relatively well under Linux with mono which is interesting when like me you can't get a windows machine. However without this little change we can't get the folder structure display correctly. Could you integrate this modification? Thanks * Version Bump * Update change log * Release 2.7.0 (#351) * Enhancement to support Unix path! (#344) I'm not sure you already got a try or a feedback about it but actually pickles run relatively well under Linux with mono which is interesting when like me you can't get a windows machine. However without this little change we can't get the folder structure display correctly. Could you integrate this modification? Thanks * Release 2.6.3 (#348) * Version Bump * Update change log * Add --enableComments Flag to Command Line - Default to True (#346) * Command-Line Flag --comments - Default to True - Incl Unit Test * Changed Command Line Argument --comments to --enableComments * Added Enable Comments Option to MSBuild - Powershell - WPF Runners * Fixed Bug with enableComments Property Not Being Used in MainViewModel * Add EnableComments to the targets file * Adapt change log * Version bump to 2.7.0 * Release 2.8.0 (#355) * Enhancement to support Unix path! (#344) I'm not sure you already got a try or a feedback about it but actually pickles run relatively well under Linux with mono which is interesting when like me you can't get a windows machine. However without this little change we can't get the folder structure display correctly. Could you integrate this modification? Thanks * Release 2.6.3 (#348) * Version Bump * Update change log * Add --enableComments Flag to Command Line - Default to True (#346) * Command-Line Flag --comments - Default to True - Incl Unit Test * Changed Command Line Argument --comments to --enableComments * Added Enable Comments Option to MSBuild - Powershell - WPF Runners * Fixed Bug with enableComments Property Not Being Used in MainViewModel * Release 2.7.0 (#352) * Release 2.6.3 (#347) * Enhancement to support Unix path! (#344) I'm not sure you already got a try or a feedback about it but actually pickles run relatively well under Linux with mono which is interesting when like me you can't get a windows machine. However without this little change we can't get the folder structure display correctly. Could you integrate this modification? Thanks * Version Bump * Update change log * Add EnableComments to the targets file * Adapt change log * Version bump to 2.7.0 * #320 - Scenario Deep Linking - DHTML and HTML Output (#350) * #320 - Scenario Deep Linking - DHTML and HTML Output * #320 - Fix Failing Unit Tests * #320 - Resolved Issue with Image Resource Not Copying * #320 - Add Backward-Compatibility for Hashed Feature Path * #320 - Added Modal Dialog for Link Copy * Edit release notes * Version Bump (2.8.0) * Release 2.8.1 (#360) * Add release notes * Fix some markdown syntax things * Bump version number (2.8.3) * Version 2.8.3 * Special chars need to be replaced (#375) * Special chars need to be replaced There are some more special chars (especially german Umlaute) that need to be replaced for the match to be successfull. * Special chars need to be replaced #375 Creating test cases and fixing handling of umlauts and ampersand * Changed indentation * Fix Importing Test Results failure for MsTest (#378) * + fix null featureTreeNode in ApplyTestResultsToFeature + handle null value for GetExampleResults and defaulted to TestResult.Inconclusive * + added extra test scenario for MsTest with ignored ScenarioOutline examples * + refactored LINQ for FeatureNode in ApplyTestResultsToFeatures * Show parser failures and quit with an error (#379) * Don't swallow exceptions if parsing a feature file throws. If parsing fails we want the build to break. We don't want to silently ignore parts. * Improve NLog layout for console - Don't show datetime, loglevel and logger - Use colors - Show exception messages * Version Bump (2.9.0)
Released in version 2.9.0. |