Presentation is loading. Please wait.

Presentation is loading. Please wait.

Build Robust Web Apps in the Real WakeUpAndCode.com.

Similar presentations


Presentation on theme: "Build Robust Web Apps in the Real WakeUpAndCode.com."— Presentation transcript:

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

2

3 Why Unit Testing? > Getting Started > Writing and Running Tests > Mocking What’s Next?

4

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?

10

11

12 Unit TestsIntegration TestsUI Tests

13

14

15

16

17

18 xUnit.net references Web App being tested

19

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

24

25 Temporarily ignore tests with an optional message.

26 Correct Views? Redirect to URL? Correct Models? HTTP Code? Mock Depen- dencies! Model Populated?

27

28

29

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

31

32

33

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)

38

39 60 to 80% coverage ok?

40

41 Why Unit Testing? > Getting Started > Writing and Running Tests > Mocking What’s Next?

42 Email: shchowd@microsoft.com Twitter: @shahedCshchowd@microsoft.com@shahedC


Download ppt "Build Robust Web Apps in the Real WakeUpAndCode.com."

Similar presentations


Ads by Google