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

Eventlistener will no longer send single spaces when the test output … #523

Merged
merged 5 commits into from Jun 29, 2018

Conversation

OsirisTerje
Copy link
Member

…is empty or just whitespace #516

The eventlistener will not send anything if the test output is null, empty or just consists of whitespaces

@OsirisTerje OsirisTerje requested review from rprouse and jnm2 June 23, 2018 03:18
Copy link
Contributor

@jnm2 jnm2 left a comment

Choose a reason for hiding this comment

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

Would it be easy to write a test that creates an NUnitEventListener and processes test results with whitespace and non-whitespace output and verifies that _recorder.SendMessage is only called for only the appropriate outputs?

namespace NUnit.VisualStudio.TestAdapter.Internal
{
#if NET35

Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: empty line between the #if and the class, but no empty line between the #endif and either class.

Copy link
Member Author

Choose a reason for hiding this comment

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

removed empty line

var site = resultNode.GetAttribute("site");

Copy link
Contributor

Choose a reason for hiding this comment

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

Super silly nitpick: new whitespace added to this line.

Copy link
Member Author

Choose a reason for hiding this comment

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

Happens when a new line is inserted and spaces are default :-(

@@ -180,22 +178,21 @@ public void SuiteFinished(XmlNode resultNode)

private static readonly string NL = Environment.NewLine;
private static readonly int NL_LENGTH = NL.Length;
private IDumpXml dumpXml;
private readonly IDumpXml dumpXml;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice to see the cleanup in this file.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

{
public static bool IsNullOrWhiteSpace(this string value)
{
return value == null || value.Trim().Length == 0;
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 good to stay simple since it's not in a hot path. 👍

For comparison: https://referencesource.microsoft.com/#mscorlib/system/string.cs,55e241b6143365ef

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, just used the https://msdn.microsoft.com/en-us/library/system.string.isnullorwhitespace(v=vs.110).aspx as a reference, and under remarks this code is shown as equivalent, and it is easier than the code from the referencesource.

[TestCase(" \t")]
[TestCase(" ")]
[TestCase("")]
public void ThatIsNullOrWhiteSpaceHandlesTabs(string value)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not all of these cases are related to handling tabs. Also can we have [TestCase(null)] and [TestCase("\r\n")]?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done


namespace NUnit.VisualStudio.TestAdapter.Tests
{
#if !NETCOREAPP1_0
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we be running these tests on netcoreapp1.0?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@"<test-output stream='Progress' testid='0-1001' testname='Something.TestClass.Whatever'><![CDATA[Whatever
]]></test-output>";

private const string BlankTestoutput =
Copy link
Contributor

Choose a reason for hiding this comment

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

For both these fields, I think you'd capitalize the O since it's two words.

Copy link
Contributor

@jnm2 jnm2 left a comment

Choose a reason for hiding this comment

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

Looks good with suggestion.

@OsirisTerje
Copy link
Member Author

Seems there is some build issues with the test project running NSubstitute...... got to look at that before merging.

@@ -4,7 +4,8 @@
<PropertyGroup>
<RootNamespace>NUnit.VisualStudio.TestAdapter.Tests</RootNamespace>
<AssemblyName>NUnit.VisualStudio.TestAdapter.Tests</AssemblyName>
<TargetFrameworks>net46;netcoreapp1.0</TargetFrameworks>
<TargetFrameworks>net35;netcoreapp1.0</TargetFrameworks>
Copy link
Contributor

Choose a reason for hiding this comment

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

@OsirisTerje Changing net46 to net35 is what is causing the NuGet restore failures. Any reason not to use net46?

Copy link
Member Author

Choose a reason for hiding this comment

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

copy paste error when I reverted back from debugging this. It is very annoying that VS don't really work with multiple targets, so I always remove the .netcore one......., just my way.....

@OsirisTerje OsirisTerje merged commit 87da667 into master Jun 29, 2018
@OsirisTerje OsirisTerje deleted the Issue516-Whitespace branch June 29, 2018 16:34
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.

None yet

2 participants