hamvocke / spring-testing

A Spring Boot application with lots of test examples
https://www.martinfowler.com/articles/practical-test-pyramid.html
1.11k stars 439 forks source link

Added Karate for HTTP integration tests and mocks #5

Closed ptrthomas closed 6 years ago

ptrthomas commented 6 years ago

Karate unifies HTTP integration testing and mocks and so can replace REST-assured, wiremock, pact and even Spring mock-mvc. The interesting thing about Karate's mock-servlet approach is that it can re-use the exact same HTTP integration (or contract) test script for testing the controller with mocks and without booting the app server.

Can you take a look, see if I missed anything !

hamvocke commented 6 years ago

I can see that you're really passionate about your product and I think you have good reasons to be proud of what you've built.

This repository is intended to be the supplementary code to my blog post, which shows distinct ways to implement tests along the individual layers of the test pyramid. For this I used the tools and libraries that I've used professionally before. Karate doesn't fall into that bucket. I haven't used it before and therefore can't judge if I'd recommend it as part of the exemplary material for my blog post. It looks like a solid product and your PR shows that it is capable to implement different layers of your test pyramid.

This repo should be clear and make it easy for people to see the concepts described in the post in action. Having two different implementations for the same kind of test doesn't help with that. Even more, it would risk opening a can of worms as people would rightly ask why I didn't use Spock, Cucumber, TestNG, Mountebank, cypress.io and all the other great products out there.

This is about explaining concepts as simple as possible, not about covering all possible ways you could implement it. I'd rather have a single, concise implementation using a product I have used in anger than multiple ones just to cover all the cool tools and libraries that are out there.

I like that you made the effort and showed how you can use Karate to build a big part of the test pyramid. I suggest you establish your pull request as a fork of this repo to show how everything I describe in my blog post can be achieved using Karate. You could also go ahead and promote that fork with another blog post that goes into a little more detail, highlighting the benefits of Karate over other libs and tools.

ptrthomas commented 6 years ago

I suggest you establish your pull request as a fork of this repo to show how everything I describe in my blog post can be achieved using Karate. You could also go ahead and promote that fork with another blog post that goes into a little more detail, highlighting the benefits of Karate over other libs and tools.

This is exactly what I plan to do, thanks for validating that it may indeed work as advertised.

I did originally assume that you might be interested in evaluating alternative test-automation tools that potentially improve upon existing tools - and get into a deeper discussion - and provide feedback that would benefit the community.