Thursday, September 29, 2022

CST 438 - Week 5

Unit Testing vs. End-to-End Testing


A unit test targets a specific behavior, usually a method or an API, and should be limited to a single process. Unit tests abide by the FIRST principles: Fast, Isolated, Repeatable, Self-validating, and Timely. 
  • Fast: If unit tests are not fast, they will slow down development time. If a test takes 5 minutes to run and must be run multiple times a day, it will lead to reduced productivity.
  • Isolated: Unit tests do not depend on the results of other tests, and they focus on one specific behavior.
  • Repeatable: Tests should produce the same result each time they are run. 
  • Self-validating: The tests themselves verify whether they have passed or failed. There should be no manual interpretation of results because it takes too much time.
  • Timely: Unit tests should be written alongside the code they test. The sooner code is tested, the better.
End-to-end (E2E) tests, in contrast, target a larger part of the system. These tests focus on user workflow and simulate real-world use cases. They use real browsers and databases instead of mocks. This type of testing is important because it expands test coverage (rather than focusing on a single behavior) and verifies that an application behaves correctly in response to end-user activity. However, end-to-end tests are more difficult to implement and can be time consuming.

No comments:

Post a Comment

CST499 - Week 8

The End? I made it. This is my final week in the CS Online program here at CSUMB. I still have one final hurdle in the form of a mock techni...