Web API Development with ASP.NET Core 8 by Xiaodi Yan
Author:Xiaodi Yan
Language: eng
Format: epub
Publisher: Packt Publishing Pvt. Ltd.
Published: 2024-03-02T00:00:00+00:00
Testing the happy path and the sad path
So far, we have written some tests to cover the happy path. However, we should also test the sad path. In testing, the terms happy path and sad path are used to describe different scenarios or test cases:
Happy path: A happy path refers to the ideal or expected scenario where the code unit being tested performs as intended. The input data is valid, and the code unit produces the expected output. Happy path tests are designed to validate the typical or desired behavior of the code unit. These tests ensure that the code works as expected without any errors or exceptions when the input data is valid. For example, in the GetInvoiceAsync(Guid id) method, the happy path is that the invoice with the specified ID exists in the database, and the method returns the invoice.
Sad path: A sad path, also known as the unhappy path, refers to the scenario where the code unit encounters an error or exception. The input data may be invalid, or the dependencies may not work as expected. Sad path tests are designed to validate whether the code unit can handle errors or exceptions gracefully. For example, in the GetInvoiceAsync(Guid id) method, the sad path is that the invoice with the specified ID does not exist in the database, and the method returns the 404 Not Found error.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12524)
Hello! Python by Anthony Briggs(9869)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9759)
The Mikado Method by Ola Ellnestam Daniel Brolund(9749)
Dependency Injection in .NET by Mark Seemann(9295)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8260)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7743)
Grails in Action by Glen Smith Peter Ledbrook(7669)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7519)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(6751)
Microservices with Go by Alexander Shuiskov(6518)
Practical Design Patterns for Java Developers by Miroslav Wengner(6416)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6394)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6380)
Angular Projects - Third Edition by Aristeidis Bampakos(5774)
The Art of Crafting User Stories by The Art of Crafting User Stories(5305)
NetSuite for Consultants - Second Edition by Peter Ries(5248)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5067)
Kotlin in Action by Dmitry Jemerov(5021)
