Goal is to demonstrate how to create a passing test for a more complex project. Student will update all four unit test cases for both employee object type and contractor. The topic of subjectivity is covered to student during this video so the student knows there's no absolute process but rather good unit tests are desiged on a cases by case basis depending on the size/complexity of the project.
- [Voiceover] Okay, we are now in the green phase,…and what we want to do is update…our test methods to pass.…If you recall in our last video,…we had all of them fail as we expected.…So, for example, in this method,…CalculateWeeklySalaryforEmployeeTest,…we were expecting a value in the string,…a salary of 2800 but instead,…it indicated $1.…That's simply because we don't have the formula…that we expect in the salary.…
So let's go ahead and do that.…That formula should be 40 times wage,…and let's update the rest of the methods also.…For the Contractor, the formula will be…weeklyhours times wage.…Our last two test methods…is to actually test that the response…and the expectedResponse are not equal.…So to do that, let's just force the string…of expectedResponse to be different.…
We'll do that by just adding,…let's say, Problem 1.…And likewise for the Contractor version…of this method, we'll add…Problem 2.…Okay.…So now, ideally,…if we run all our tests,…they should all pass,…and they do.…
Great!…Keep in mind that as we write test,…
Released
4/11/2016In this course, Reynald Adolphe explains the principles of test-driven development and shows how to apply them to two different C# workflows. First, he creates a new test-driven project. He writes the test cases before the code to drive the design of the program. In the second scenario, he writes test cases for an existing C# project, to find bugs before it goes live. Along the way, Reynald uses Microsoft's MSTest, but he also introduces other testing tools (such as the unit testing framework xUnit and the mocking framework Moq) and theories (such as the red-green-refactor mantra and SOLID principles) that make test-driven development so efficient.
- Different approaches to testing
- Using testing tools and mocking frameworks
- Creating a simple C# test-driven project
- Adding a failing test
- Updating tests to pass
- Refactoring code
- Using Moq to test data
Share this video
Embed this video
Video: Update test to pass