mmport80

mmport80

Property Testing a CRUD API

I am sketching out how to test a CRUD API.

My idea is to create a simplified model / FSM, generate different states and test for properties based on the model.

E.g. assuming everything’s successful,

  1. GET /users
  2. POST /create/id/9
  3. DELETE /delete/id/9
  4. GET /users

users from 1. and 4. should be the same

Then do the a similar test when

  1. GET /users
  2. POST /create/id/8
  3. GET /users

3.'s users should have one more entry etc.

or when

  1. GET /users
  2. POST /create/id/11
  3. DELETE /delete/id/54 //:error
  4. GET /users

Again 4’s users should have one more entry.

basically, setting properties for as many cases I can, and then testing with random test-cases.

Problem is, I cannot find much material online, I am sure it is pretty standard esp. as CRUD APIs are pretty standard.. (?)

Most Liked

david_ex

david_ex

From What is a Property (online version of the book, prior to having been edited):

Finally, there’s a rare but great type of modeling that may be available, called “the oracle”. An oracle is a reference implementation, possibly coming from a different language or software package, and can therefore act as a pre-written model. The only thing required of the programmer to test the system is to compare their implementation with the oracle and ensure the same results are given.

idi527

idi527

Problem is, I cannot find much material online

I think https://propertesting.com/ is pretty good.

dimitarvp

dimitarvp

For a server-side rendered CRUD website I’d concentrate on making StreamData generators of controller parameters – omit mandatory fields, send fields with invalid data in them, try and update or delete non-existing IDs, send fields that your app isn’t at all expecting. StreamData can be really alien at start but when you experiment with it for a weekend you can do some seriously powerful data generators with it!

Where Next?

Popular in Questions Top

skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

Other popular topics Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 44778 311
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New

We're in Beta

About us Mission Statement