From the course: C# Unit Testing with xUnit
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Writing your first unit test with xUnit - C# Tutorial
From the course: C# Unit Testing with xUnit
Writing your first unit test with xUnit
- [Instructor] In this video, let's discuss writing your first unit test in the xUnit framework. Since we've already run our first test by using the default test that was created for us when we created the hello calcs test project, now let's look at how to write our own test. A basic xUnit test consists of a public method with no parameters marked by the fact attribute. (keyboard clacking) We can write our own test by creating a fact attribute, then create a public method called MyFirstTest. Now, if we go back to our test panel and rerun it, you should see that our test will show up. Since we're not actually testing anything, it's always going to pass, just like the original test that was created in this project. Let's go ahead and write our first assertion. (keyboard clacking) Now let's create a new fact, and we're going to call this public method TestIfTrueIsTrue. One thing to keep in mind, since we're going to be…