DEV Community

loading...

Discussion on: Why writing integration tests on a C# API is a productivity booster

Collapse
jwp profile image
John Peters • Edited

Great article Tim.

While Cypress takes about a week to learn, it is really a great testing framework for true E2E.

Amazingly enough it can do everything.

Collapse
gandalfarcade profile image
Chris Mumford

Cypress is an excellent tool. It provides assurances that you're front end works as defined by your tests. Ideally it'll be accompanied by your unit and integration tests to ensure you are also testing things in isolation, easily mocking certain scenarios that might be harder to achieve using Cypress.

Collapse
jwp profile image
John Peters • Edited

Agreed, I have been reluctantly using Karma/Jasmine for unit tests. It's very time consuming, and dependent on knowing all dependencies (which only show when running the test). This includes 3rd party components of which you may not know the dependency chain.

With Cypress' ability to intercept outbound and inbound requests; like Swagger we can inject boundary conditions on the outbound s. But unlike Swagger we can also inject behaviors into what was returned.

Its built-in HTTP client opens up everything else. We're not just limited to interception.

The new way of thinking about (web side) E2E and Unit Tests is that they can be combined into one easy and fun tool. Now we just need to convince all the old timers.

Collapse
timdeschryver profile image
Tim Deschryver Author

I agree that cypress is a great tool!
But I also want to test my API in isolation (without having a front-end), these are faster to run and takes less time to write.

I do this by creating a c# test, see How to test your C# web API to see how I do it.

Collapse
jwp profile image
John Peters

Agreed, we too have extensive back end tests as well