Download presentation
Presentation is loading. Please wait.
Published bySybil Morrison Modified over 9 years ago
1
Build Robust Web Apps in the Real World @shahedC WakeUpAndCode.com
2
Why Unit Testing? > Getting Started > Writing and Running Tests > Mocking What’s Next?
4
> Nothing new to learn > Error-prone > Expensive > Slower
5
> Less human error > Faster! > Decreasing costs > Learning curve
6
Legacy New/ Improved Design Patterns S.O.L.I.D.TDDRefactorRestructure SRP OCP LSP ISP DIP
7
Source: https://msdn.microsoft.com/en-us/library/jj159342.aspx
8
Why Unit Testing? > Getting Started > Writing and Running Tests > Mocking What’s Next?
11
Unit TestsIntegration TestsUI Tests
16
Verify NUnit assembly Also add Web App being tested
18
[TestFixture] above public test class [Test] for public methods without parameters [TestCase] for methods with parameters
19
Build Solution Run Tests in Test Explorer
20
Run Tests from code UI
21
Verify actual result against expected result Note “var” keyword
22
Verify something is equal to something else
24
Temporarily ignore tests with an optional message.
25
Correct Views? Redirect to URL? Correct Models? HTTP Code? Mock Depen- dencies! Model Populated?
28
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
31
Why Unit Testing? > Getting Started > Writing and Running Tests > Mocking What’s Next?
33
Smoke Tests New Features Edge Cases
34
Cost of Adding Unit Tests Cost of Not Having Unit Tests Bugs Features Expenses
35
Dependency Injection Inversion of Control
36
Views & ViewModels Controllers Service Layer Repository Layer Entity Framework (ORM) SQL Server (database)
38
60 to 80% coverage ok?
39
Why Unit Testing? > Getting Started > Writing and Running Tests > Mocking What’s Next?
40
Email: shchowd@microsoft.com Twitter: @shahedCshchowd@microsoft.com@shahedC
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.