Question

I developing REST API using Scala and Play Framework 2. Looks like right now is good time for writing acceptance specifications for this web service. There are two kinds of users for this API: web site and ipad app.

So, the question is which side should I choose to write acceptance specs?


To be much more concrete, by acceptance specifications I means such kind of tests:

"user" should {
  "be able to register with login, email and pass" in {
      ... // registration process here
   }
}

Here is my check lists

Server side (scala + specs2)

  • [+] easy to integrate into build process
  • [+] more familiar with scala
  • [-] easy to miss some browser specific details (for example CORS)

Client side (js + simple ajax or some testing framework)

  • [-] harder to automate (requires node.js, v8, phantomJS or something like that)
  • [-] more familiar with scala
  • [+] all browser details are taken in account
  • [+] eat your own dog food. Ability to use server side api as a client side programmer
  • [+] kind of examples for client side programmers
Était-ce utile?

La solution

In my opinion the tests you called "Server side" could be unit tests, they should be fast and integrated into the build process, there you should test for API correctness, not for features like CORS, which belong to the client side.

For the client side I recommend you to use Selenium IDE, it's a browser plugin that lets you record action and assert on what happens on the page, letting you replay all the actions later on, way faster than a human could do.

I don't have experience in integrating that into a build workflow though, so if you need to have also this into your build process I suggest you to evaluate CasperJS, it has a wonderful documentation and useful testing features.

If you just need acceptance tests I would definitely go on the frontend.

Autres conseils

I believe that for acceptance test you only need to do a server side test, using a BDD framework to easily do that.

If you test through JavaScript it's sound more like a integration test.

So I thought that in REST API Scope, to make sure that your REST API are acceptable, you need to implement a test without care about who are the consumers, and test only if the simple requests come to your api are responded.

But in client side scope, you need to guarantee that the code that use the respose of the REST API are good, so you mockup your REST API (for javascript I recomend Jasmine or Sinon).

Then to test if all system are right together, you need to use a tool like Seleniun.

I hope this help you

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top