-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Conversation
@jnm2 and @halex2005 could you review this for accuracy since you are the members of the NUnit team with .NET Core experience? |
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.
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?
@jnm2 probably not the right place for that. These are the .NET Core docs and the project was created by our |
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). |
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.
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.
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 taking a look @halex2005. I have submitted tutorials for F# and VB separately, see #3858 and #3859
@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! |
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 😄 |
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.
Overall, this looks great. I found a few small nits to fix, and then we'll
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 |
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 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 |
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.
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. |
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.
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"); |
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 $
is superfluous here. Let's remove it.
@BillWagner all nits on the NUnit C# tutorial have been de-nitted and changes pushed ready for re-review. |
Thanks again @rprouse We appreciate it. I'll |
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