-
Notifications
You must be signed in to change notification settings - Fork 323
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
Show proper warning message no tests to run because testcasefilter #1656
Show proper warning message no tests to run because testcasefilter #1656
Conversation
…-no-tests-message-on-filter
@@ -6,8 +6,8 @@ | |||
<!-- Name of the elements must be in sync with test\Microsoft.TestPlatform.TestUtilities\IntegrationTestBase.cs --> | |||
<NETTestSdkPreviousVersion>15.5.0</NETTestSdkPreviousVersion> | |||
|
|||
<MSTestFrameworkVersion>1.3.2</MSTestFrameworkVersion> | |||
<MSTestAdapterVersion>1.3.2</MSTestAdapterVersion> | |||
<MSTestFrameworkVersion>1.3.1</MSTestFrameworkVersion> |
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 required to show proper diagnostic info on test failures of vstest repo. Related to microsoft/testfx#451 . We should fix the trx parsing logic in vstest repo.
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.
Lets create a tracking bug for this.
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.
Created one #1658
this.requestData.MetricsCollection.Add(TelemetryDataConstants.TimeTakenInSecByAllAdapters, totalTimeTakenByAdapters); | ||
private static void LogWarningOnNoTestsDiscovered(IEnumerable<string> sources, string testCaseFilter, IMessageLogger logger) | ||
{ | ||
var sourcesString = string.Join(" ", sources); |
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.
Actual change is here for discovery scenario.
@@ -170,5 +186,22 @@ protected override void InvokeExecutor(LazyExtension<ITestExecutor, ITestExecuto | |||
|
|||
return result; | |||
} | |||
|
|||
private static string TestCaseFilterToShow(string testCaseFilter) |
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 is dead code.
@@ -11,7 +11,10 @@ | |||
<!--<EnableCodeAnalysis>true</EnableCodeAnalysis>--> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<EmbeddedResource Include="Resources\Resources.resx" /> | |||
<EmbeddedResource Include="Resources\Resources.resx"> |
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.
To Make Resources.Designer.cs
updates based on Resources.resx
.
Example: SettingsMigrator.exe E:\MyTest\MyTestSettings.testsettings | ||
Example: SettingsMigrator.exe E:\MyTest\MyOldRunSettings.runsettings</source> | ||
<target state="translated">Platné použití: SettingsMigrator.exe <kompletní cesta k souboru testsettings nebo runsettings, který se má migrovat> | ||
<source>Valid usage: |
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.
These resources update missed in #1620
/cc @singhsarab @kaadhina
@@ -147,6 +147,12 @@ public void Initialize(TestLoggerEvents events, string testRunDirectory) | |||
events.TestRunMessage += this.TestMessageHandler; | |||
events.TestResult += this.TestResultHandler; | |||
events.TestRunComplete += this.TestRunCompleteHandler; | |||
|
|||
// Register for the discovery events. |
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.
@@ -6,8 +6,8 @@ | |||
<!-- Name of the elements must be in sync with test\Microsoft.TestPlatform.TestUtilities\IntegrationTestBase.cs --> | |||
<NETTestSdkPreviousVersion>15.5.0</NETTestSdkPreviousVersion> | |||
|
|||
<MSTestFrameworkVersion>1.3.2</MSTestFrameworkVersion> | |||
<MSTestAdapterVersion>1.3.2</MSTestAdapterVersion> | |||
<MSTestFrameworkVersion>1.3.1</MSTestFrameworkVersion> |
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.
Lets create a tracking bug for this.
@@ -135,93 +135,174 @@ private void LoadTestsFromAnExtension(string extensionAssembly, IEnumerable<stri | |||
|
|||
foreach (var discoverer in discovererToSourcesMap.Keys) | |||
{ | |||
Type discovererType = null; | |||
this.DiscoverTestsFromSingleDiscoverer(discoverer, discovererToSourcesMap, context, discoverySink, logger, ref discoverersFromDeprecatedLocations, ref totalAdaptersUsed, ref totalTimeTakenByAdapters); |
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.
Avoid using ref and out in C#. Check this CA violation for more details.
Additional read: https://www.simplethread.com/ten-c-keywords-that-you-shouldne28099t-be-using/
Solution is to create multiple methods out the method with each method returning single value.
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.
Check other methods as well. Example: TryToLoadDiscoverer
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.
Avoid using ref and out in C#. Check this CA violation for more details.
Additional read: https://www.simplethread.com/ten-c-keywords-that-you-shouldne28099t-be-using/
Solution is to create multiple methods out the method with each method returning single value.
Reduced the ref usage. Only using in one place now.
Check other methods as well. Example: TryToLoadDiscoverer
TryDoSomework
is very well used ways in BCL libraries. I would like to keep it as it is.
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.
Using out keyword is not wrong but is not recommended. Please check above links for reasons. To get it cleared, what should be the recommended approach, we can have a second opinion. @cltshivash Can you recommend what should be the approach here?
ref double totalAdaptersUsed, | ||
ref double totalTimeTakenByAdapters) | ||
{ | ||
if (TryToLoadDiscoverer(discoverer, logger, out var discovererType) == false) |
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.
Nit: DiscovererEnumerator.TryToLoadDiscoverer
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.
Done.
ref double totalAdaptersUsed, | ||
ref double totalTimeTakenByAdapters) | ||
{ | ||
if (TryToLoadDiscoverer(discoverer, logger, out var discovererType) == false) |
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.
TryToLoadDiscoverer already returns bool. No need for == false.
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.
!
is difficult to read. That's why kept false explicitly.
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.
if(!succuess) is more readable than if(success == false). We can have a second opinion here as well to know what is the recommended approach here.
|
||
// if instantiated successfully, get tests | ||
try | ||
this.testPlatformEventSource.AdapterDiscoveryStart(discoverer.Metadata.DefaultExecutorUri.AbsoluteUri); |
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.
Nit: line spacing
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.
Don't see any.
|
||
|
||
/// <summary> | ||
/// Looks up a localized string similar to No test is available for testcase filter `{0}` in {1}. |
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.
No test is available
or No tests are available
?
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.
No test is available
has been used in already existing resource string. To keep it consistency keeping it as it is.
{ | ||
internal static string ShortenTestCaseFilterIfRequired(string testCaseFilter) | ||
{ | ||
var maxLength = 256; |
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.
We can move it to class const
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.
Done.
|
||
if (testCaseFilter.Length > maxLength) | ||
{ | ||
shortenTestCaseFilter = testCaseFilter.Substring(0, maxLength) + "..."; |
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.
We can use ternary operator here as if else contains single line of code.
return testCaseFilter.Length > maxLength ? testCaseFilter.Substring(0, maxLength) + "..." : testCaseFilter
OR
return testCaseFilter.Substring(0, Math.Min(testCaseFilter.Length, maxLength))
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.
For better readability not using terninary operator.
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.
That what case ternary operator should be used?
Ternary operators are useful for such scenarios only where if and else conditions have single lines
// Register for the discovery events. | ||
events.DiscoveryMessage += this.TestMessageHandler; | ||
|
||
// TODO Get changes from https://github.com/Microsoft/vstest/pull/1111/ |
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.
Should there be a tracking item for this?
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 have reopened the PR
@@ -236,7 +238,7 @@ private void TestRunRequest_OnRunCompletion(object sender, TestRunCompleteEventA | |||
var testsFoundInAnySource = (e.TestRunStatistics == null) ? false : (e.TestRunStatistics.ExecutedTests > 0); | |||
|
|||
// Indicate the user to use testadapterpath command if there are no tests found | |||
if (!testsFoundInAnySource && string.IsNullOrEmpty(CommandLineOptions.Instance.TestAdapterPath)) | |||
if (!testsFoundInAnySource && string.IsNullOrEmpty(CommandLineOptions.Instance.TestAdapterPath) && this.commandLineOptions.TestCaseFilterValue == 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.
string.IsNullOrEmpty instead of == 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.
TestCaseFilterValue
can't be empty because we won't accept empty value.
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.
Approved with suggestions
@abhishkk As suggestions are around personal choices of nits. I'm going ahead with merge. Will create another PR if required. |
Description
For #1643
a. Small scrollpane for
output
->test
b. Lengthy message can impact the performance of VS
Example issue
First I have chosen 60 character as max testcasefilter length. While testing realized that max length 256 characters looks good.
For #1569
Related issue
#1643
#1569