Test tool that verifies request/response against a RAML


#1

Hi all

I’ve written a test tool (https://github.com/nidi3/raml-tester) that verifies that given requests and/or responses are correct according to a RAML.

Eg. it can be used during integration testing to assure that a service implementation is following the API definition.
Additionally, it can analyze the coverage of a test suite. I.e. if all elements of a RAML (resources, parameters, headers, …) are used in at least one test.

It works together with spring, apache httpclient or in a plain servlet environment. There’s also a proxy version of it so it can also be used in non-JVM environments.

Currently, it supports the whole RAML 0.8 standard apart from security.

Feel free to try it out. Any feedback is welcome!


#2

Superb concept.


#3

This is the best testing RAML framework I’ve seen and thus I’ve adopted it. I’m using it to test APIs built in Clojure.

It does the right thing in the sense that, instead of trying to auto-test your API (which can only work for the most naive things), raml-tester invites you to fully cover your API with integration tests and, as you’re doing so, validates that the requests and responses conform to the RAML spec and its related schemas.

This is plain genius.

Also, there is a proxy (raml-tester-proxy) that you can use if you don’t want or can’t embed raml-tester in your project’s integration tests. raml-tester-proxy is great for scenarios where QA would build an independent set of tests (maybe by using SOAPui and its RAML plugin) and thus would not want to alter the embedded integration tests of a project.

Big thank you Stephan, this is an awesome contrib.


#4

Great! It should definitely go to the project page. @ddossot Have you had the chance to test Abao?


#5

I gave Abao a quick try but it didn’t work for my needs: testing based on the example requests/responses was not enough. Also I wanted the possibility to wire the RAML verifier right in my project’s integration tests, in the same VM, and write regular Junit/clojure.test assertions.


#6

@ddossot when you talk about auto-test an API, did you know a project that it’s able to do this.
I want to build test from my Raml file to test my API, but i just want to test the most naive things as you said (path, queryParam, body, schema)…


#7

@y0an Try Abao then.


#8

Good framework .


#9

Hi ghuder,

First of all, thank you for putting your hard work into this excellent testing tool. I have just a small question though. Is there a reason why this is compiled against java 7?
Projects that still use java 6 unfortunately cannot take the benefit of this tool. Maybe a java 6 compliant fork could be created? It’s just a suggestion :smile:


#10

Hi Finch

The only reason for java 7 is that java 6 is officially dead since feb 2013.
It should be possible to do a version for java 6, but that’s not exactly my highest priority.


#11

Ironically, I now have also this problem at my day job. We’re stuck with java 6 and I’d like to use raml-doc.

According to http://stackoverflow.com/questions/7661980/compiling-java-7-to-java-6, this can be achieved by simply change the version byte in all class files.

Naturally, this is a big hack and I have no garantees that it works, but if you like to test it, just run

mvn guru.nidi.maven.plugins:tools-maven-plugin:backport7to6-artifact -DgroupId=guru.nidi.raml -DartifactId=raml-tester -Dversion=0.8.3

it generates a raml-tester-0.8.3-backported7to6.jar with the version byte set to java 6.


#12

Hi Ghuder,

I might give your solution a try in the near future. Currently on my day job, I fixed this by asserting the JSON response with an expected JSON. For this, I use org.skyscreamer:jsonassert . This test library also contains some convenient assertions for JSON structures.


#14

Hi Ghuder,

Thanks for the great tool, I am trying to use the 0.9.1 version which is not supporting most my RAML1.0 spec elements such as ‘allowedTargets’,‘name’…etc. Can you let me know if any other version that supports RAML1.0 spec? Please adice me an alternative .Thank you.