Download presentation
Presentation is loading. Please wait.
Published byEllen McCoy Modified over 9 years ago
1
Build Robust Web Apps in the Real World @shahedC WakeUpAndCode.com
3
Why Unit Testing? > Getting Started > Writing and Running Tests > Mocking What’s Next?
5
> Nothing new to learn > Error-prone > Expensive > Slower
6
> Less human error > Faster! > Decreasing costs > Learning curve
7
Legacy New/ Improved Design Patterns S.O.L.I.D.TDDRefactorRestructure SRP OCP LSP ISP DIP
8
Source: https://msdn.microsoft.com/en-us/library/jj159342.aspx
9
Why Unit Testing? > Getting Started > Writing and Running Tests > Mocking What’s Next?
12
Unit TestsIntegration TestsUI Tests
18
xUnit.net references Web App being tested
20
public test class [Fact] for public methods without parameters [Theory] and [InlineData] for methods with parameters
21
Build Solution Run Tests in Test Explorer
22
Verify actual result against expected result Note “var” keyword
23
Verify that expected view equal to returned view
25
Temporarily ignore tests with an optional message.
26
Correct Views? Redirect to URL? Correct Models? HTTP Code? Mock Depen- dencies! Model Populated?
30
Mocks Pre-programmed with expected results, doesn’t actually connect to DB, behavior verification. Fakes Working examples, but not production-ready (e..g in-memory database) Stubs Provides canned answers
34
Smoke Tests New Features Edge Cases
35
Cost of Adding Unit Tests Cost of Not Having Unit Tests Bugs Features Expenses
36
Dependency Injection Inversion of Control
37
Views & ViewModels Controllers Service Layer Repository Layer Entity Framework (ORM) SQL Server (database)
39
60 to 80% coverage ok?
41
Why Unit Testing? > Getting Started > Writing and Running Tests > Mocking What’s Next?
42
Email: shchowd@microsoft.com Twitter: @shahedCshchowd@microsoft.com@shahedC
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.