build robust web apps in the real world @shahedc wakeupandcode.com

Download Build Robust Web Apps in the Real World @shahedC WakeUpAndCode.com

If you can't read please download the document

Upload: ellen-mccoy

Post on 27-Dec-2015

220 views

Category:

Documents


0 download

TRANSCRIPT

  • Slide 1
  • Build Robust Web Apps in the Real World @shahedC WakeUpAndCode.com
  • Slide 2
  • Slide 3
  • Why Unit Testing? > Getting Started > Writing and Running Tests > Mocking Whats Next?
  • Slide 4
  • Slide 5
  • > Nothing new to learn > Error-prone > Expensive > Slower
  • Slide 6
  • > Less human error > Faster! > Decreasing costs > Learning curve
  • Slide 7
  • Legacy New/ Improved Design Patterns S.O.L.I.D.TDDRefactorRestructure SRP OCP LSP ISP DIP
  • Slide 8
  • Source: https://msdn.microsoft.com/en-us/library/jj159342.aspx
  • Slide 9
  • Why Unit Testing? > Getting Started > Writing and Running Tests > Mocking Whats Next?
  • Slide 10
  • Slide 11
  • Slide 12
  • Unit TestsIntegration TestsUI Tests
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • xUnit.net references Web App being tested
  • Slide 19
  • Slide 20
  • public test class [Fact] for public methods without parameters [Theory] and [InlineData] for methods with parameters
  • Slide 21
  • Build Solution Run Tests in Test Explorer
  • Slide 22
  • Verify actual result against expected result Note var keyword
  • Slide 23
  • Verify that expected view equal to returned view
  • Slide 24
  • Slide 25
  • Temporarily ignore tests with an optional message.
  • Slide 26
  • Correct Views? Redirect to URL? Correct Models? HTTP Code? Mock Depen- dencies! Model Populated?
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Mocks Pre-programmed with expected results, doesnt actually connect to DB, behavior verification. Fakes Working examples, but not production-ready (e..g in-memory database) Stubs Provides canned answers
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Smoke Tests New Features Edge Cases
  • Slide 35
  • Cost of Adding Unit Tests Cost of Not Having Unit Tests Bugs Features Expenses
  • Slide 36
  • Dependency Injection Inversion of Control
  • Slide 37
  • Views & ViewModels Controllers Service Layer Repository Layer Entity Framework (ORM) SQL Server (database)
  • Slide 38
  • Slide 39
  • 60 to 80% coverage ok?
  • Slide 40
  • Slide 41
  • Why Unit Testing? > Getting Started > Writing and Running Tests > Mocking Whats Next?
  • Slide 42
  • Email: [email protected] Twitter: @[email protected]@shahedC