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,
- GET /users
- POST /create/id/9
- DELETE /delete/id/9
- GET /users
users from 1. and 4. should be the same
Then do the a similar test when
- GET /users
- POST /create/id/8
- GET /users
3.'s users should have one more entry etc.
or when
- GET /users
- POST /create/id/11
- DELETE /delete/id/54 //:error
- 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
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
Problem is, I cannot find much material online
I think https://propertesting.com/ is pretty good.
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!
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









