Skip to content

Conversation

@fgreinacher
Copy link
Contributor

@jpreese this addresses some of your comments on my fix PR. Do you think this goes in the right direction? I'm also very open for feedback on the naming.

@fgreinacher fgreinacher requested a review from jpreese July 9, 2018 19:11
@jpreese
Copy link
Member

jpreese commented Jul 9, 2018

Awesome! I think I like this approach better than the categories, a lot easier to run. My only big comment would be, if I recall correctly we have some tests that still check IsUnixPlatform() and add/remove test data based on the environment.

I think it would be a lot better if we werent modifying test data within the test (avoiding logic in tests), and just splitting those out into new tests that we can then just flat out skip for Linux.

Does that make sense?

// Assert
Assert.IsNotNull(result);
}

Copy link
Member

Choose a reason for hiding this comment

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

This is one example, I think there was at least one more.

                 // These are no problems on Unix platforms
                 yield return @"..\";	       
                 yield return @"aaa\vv..\";	
                 yield return @"a..\b";	                 

I think I'd rather see this in another test and we could add this skip attribute

Copy link
Contributor Author

Choose a reason for hiding this comment

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

6d58566 splits this to separate tests. I'm not sure (but also not very emotional) on what I like better 🤣

Copy link
Member

@jpreese jpreese Jul 9, 2018

Choose a reason for hiding this comment

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

haha I think the idea is better, anyway. You typically want to avoid any sort of logic within a test.

For the approach, I don't think I'd have a test that calls another test with different input. I was more thinking just explicitly put the input in the test and run the test, even if the arrange/act are similar or exact.

So you'd have something like

[Skip on Linux]
public void MockDirectoryInfo_FullName_UNCPaths_ShouldReturnNormalizedPath()
{
  var input = object array of uncpaths {} // arrange
  // act
  // assert
}

There really isn't a reason, that I can see anyway, to have that test data outside of the test itself (especially public ❤️ )

Copy link
Member

Choose a reason for hiding this comment

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

If that's still a little bit confusing, let me know and I could whip up an example. I just think its better to be a little be repetitive in tests vs. trying to avoid repeating yourself. When it comes to tests, I think it's generally better to show as much intent/be expressive as possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's what I also didn't like. b6a744c tries to improve on this.

Copy link
Member

Choose a reason for hiding this comment

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

Woo! I just saw one more, and then I think we're good. Thanks for this! 🎉

{
internal static class SkipReason
{
public const string NoDrivesOnUnix = "Unix does not have the concept of Drives";
Copy link
Member

Choose a reason for hiding this comment

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

I think there are a couple tests that are skipped due to Illegal characters

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, added a new reason for that


namespace System.IO.Abstractions.TestingHelpers.Tests
{
internal static class SkipReason
Copy link
Member

Choose a reason for hiding this comment

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

I'd probably put this in its own class. You?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, will do

@jpreese jpreese mentioned this pull request Jul 9, 2018
@jpreese
Copy link
Member

jpreese commented Jul 9, 2018

Looking great! This will be so much better than that if(linux) block everywhere.

@rkoeninger
Copy link
Contributor

rkoeninger commented Jul 9, 2018

Most minor of quibbles, but I would call it WindowsOnly instead, as Windows is the weird one, not Linux, BSD, macOS, iOS and Android, which collectively form the norm among target platforms.

Yes, I feel rhyming grants this critique a little extra legitimacy.

@fgreinacher
Copy link
Contributor Author

That’s actually a good idea @rkoeninger - makes it much clearer IMO! Will change

@fgreinacher fgreinacher changed the title Introduce SkipOnUnixAttribute and use it to simplify tests Introduce WindowsOnlyAttribute and use it to simplify tests Jul 10, 2018

[TestCaseSource("MockDirectoryInfo_FullName_Data_WindowsOnly")]
[WindowsOnly(WindowsSpecifics.UNCPaths)]
public void MockDirectoryInfo_FullName_ShouldReturnNormalizedPath_WindowsOnly(string directoryPath, string expectedFullName)
Copy link
Member

Choose a reason for hiding this comment

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

Another case of a test calling a test.

@jpreese
Copy link
Member

jpreese commented Jul 11, 2018

I'll merge this when the build starts passing. I'm excited for this one!

@fgreinacher
Copy link
Contributor Author

Whenever I defeat Git 😛

@jpreese jpreese merged commit 3207522 into TestableIO:master Jul 11, 2018
@jpreese
Copy link
Member

jpreese commented Jul 11, 2018

Woo! Awesome 🎉

@fgreinacher
Copy link
Contributor Author

Done 🎉 Please squash this crappy commits when merging 🤖

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.

3 participants