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

Adds NUnit test tutorial for .NET Core C# #3856

Merged
merged 5 commits into from
Dec 5, 2017

Conversation

rprouse
Copy link
Contributor

@rprouse rprouse commented Dec 1, 2017

Summary

The Getting Started with Testing page for .NET Core has tutorials for xUnit and MSTest. This adds documentation and a sample project for NUnit in C#. To keep the size of the PRs manageable, I will submit F# and Visual Basic tutorials separately.

See #1785 - Document NUnit in .NET Core Guide > Unit Testing

@rprouse
Copy link
Contributor Author

rprouse commented Dec 1, 2017

@jnm2 and @halex2005 could you review this for accuracy since you are the members of the NUnit team with .NET Core experience?

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.

Lgtm. Worth a note that you'll need the <DebugType>Full</DebugType> workaround if you start multitargeting and target .NET Framework, or not the right place?

@rprouse
Copy link
Contributor Author

rprouse commented Dec 1, 2017

@jnm2 probably not the right place for that. These are the .NET Core docs and the project was created by our dotnet new nunit template and is unchanged.

@rprouse
Copy link
Contributor Author

rprouse commented Dec 1, 2017

Build failures look unrelated.


You can read about those combinations in these walkthroughs:

* Create unit tests using [*XUnit* and *C#* with the .NET Core CLI](unit-testing-with-dotnet-test.md).
* Create unit tests using [*NUnit* and *C#* with the .NET Core CLI](unit-testing-with-nunit.md).
* Create unit tests using [*MSTest* and *C#* with the .NET Core CLI](unit-testing-with-mstest.md).
* Create unit tests using [*XUnit* and *F#* with the .NET Core CLI](unit-testing-fsharp-with-dotnet-test.md).

Choose a reason for hiding this comment

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

In fact, dotnet new nunit can generate projects for F# and Visual Basic too. You can use -lang F# or -lang VB switches to the command for that. Just like in docs for XUnit and MSTest. Consider to add two more pages for these languages too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for taking a look @halex2005. I have submitted tutorials for F# and VB separately, see #3858 and #3859

@BillWagner
Copy link
Member

@rprouse Thanks for writing all three NUnit tutorials. We really appreciate it.

I'll be reviewing all three starting today. I want to give them all a thorough review. You'll get any detailed feedback in the next few days.

Thanks again!

@rprouse
Copy link
Contributor Author

rprouse commented Dec 4, 2017

Thanks @BillWagner. FYI I used the existing xUnit and MSTest tutorials as templates and I walked through all of them using the samples I created. I also lead the NUnit team if that helps 😄

Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

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

Overall, this looks great. I found a few small nits to fix, and then we'll :shipit:

Thanks again for writing these.


This tutorial takes you through an interactive experience building a sample solution step-by-step to learn unit testing concepts. If you prefer to follow the tutorial using a pre-built solution, [view or download the sample code](https://github.com/dotnet/docs/blob/master/samples/core/getting-started/unit-testing-using-nunit/) before you begin. For download instructions, see [Samples and Tutorials](../../samples-and-tutorials/index.md#viewing-and-downloading-samples).

### Creating the source project
Copy link
Member

Choose a reason for hiding this comment

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

This should be an H2 ## instead of H3 ###


Change the directory back to the *unit-testing-using-nunit* directory. Run [`dotnet sln add PrimeService/PrimeService.csproj`](../tools/dotnet-sln.md) to add the class library project to the solution.

### Install the NUnit project template
Copy link
Member

Choose a reason for hiding this comment

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

Also H2


### Install the NUnit project template

The NUnit test project templates need to be installed before creating a test project. This only needs to be done once. Run [`dotnet new -i NUnit3.DotNetNew.Template`](../tools/dotnet-new.md) to install the NUnit templates.
Copy link
Member

Choose a reason for hiding this comment

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

Let's clarify that this is a per machine install. Meaning the command needs to be done once on each development machine where you'll create new NUnit projects.

{
var result = _primeService.IsPrime(1);

Assert.IsFalse(result, $"1 should not be prime");
Copy link
Member

Choose a reason for hiding this comment

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

The $ is superfluous here. Let's remove it.

@rprouse
Copy link
Contributor Author

rprouse commented Dec 5, 2017

@BillWagner all nits on the NUnit C# tutorial have been de-nitted and changes pushed ready for re-review.

@BillWagner
Copy link
Member

Thanks again @rprouse We appreciate it.

I'll :shipit: now. You should see the changes on the live site in the next day or two, on our next regular publish cycle.

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.

5 participants