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 Why Unit Testing? > Getting Started > Writing and Running Tests > Mocking What’s Next?

3

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?

9

10

11 Unit TestsIntegration TestsUI Tests

12

13

14

15

16 Verify NUnit assembly Also add Web App being tested

17

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

23

24 Temporarily ignore tests with an optional message.

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

26

27

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

29

30

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

32

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)

37

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


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

Similar presentations


Ads by Google