I am planning to add test suit for my web-project and some mobile api. I finalise Midje and clojure.test to test each line of code basically for (Unit Testing),
but I am unable to figure out test libraries to test end-to-end api.
what about clj-webdriver or any other better option..?
thanks and appreciation for any help.
I use combination of clj-webdriver and Kerodon based tests:
I use clj-webdriver for testing scenarios that require executing JavaScript. Because these tests use a real browser, they are slow, so any scenario that doesn't need to use clj-webdriver should not use it. This is a tutorial about setting up clj-webdriver for a fresh Compojure based application.
I use Kerodon for all tests that don't require executing JavaScript. Kerodon doesn't start a real application server and browser so it's much faster. It's inspired by Ruby's Capybara. This is a tutorial about setting up Kerodon for a Compojure application that also includes the Kerodon API overview.
One problem with this approach is that clj-webdriver and Kerodon have a different API. Let's say you have a test that was initially written using Kerodon, since it didn't require JavaScript. If you need to execute JavaScript in the test, you will need to re-write it using clj-webdriver API. This isn't a huge problem, though, but it would be nice if there is a project that wraps both of these and would support changing driver option. Or if this feature would be part of Kerodon.
Other than 2 APIs, this approach was working well for me.
One option is to use ring.mock to test your services through their exposed endpoints. If you are just testing API responses to various requests this is the direction I'd go.
On my current project we do use clj-webdriver to do some testing through a web browser which helps test our UI. The tests we've written have helped catch regressions though we are still trying to have the output be easy to interpret. We try not to do too much in these tests because of brittleness and difficulty in narrowing down what is broken when a test fails.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With