Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Model-based testing: gone and back again - .NET...

Model-based testing: gone and back again - .NET Perth March 2020

My first job in software was as a tester using model-based testing. After switching to development, I've found that writing tests is more work, and gives me less confidence than before. In this talk, I'll explain what's missing in the way we write tests now, some more benefits of model-based testing, and why I'm going back to my roots.

Links:
https://saucelabs.com/blog/the-challenges-and-benefits-of-model-based-testing
https://statecharts.github.io/
http://graphwalker.github.io/
https://altom.gitlab.io/altwalker/altwalker/
https://xstate.js.org/
https://gannettdigital.github.io/simulato/
http://mit.bme.hu/~micskeiz/pages/modelbased_testing.html#tools

Avatar for Benjamin Lowry

Benjamin Lowry

March 03, 2020
Tweet

More Decks by Benjamin Lowry

Other Decks in Programming

Transcript

  1. The trouble with testing • Hard to find time to

    write good tests • Avoid writing tests because I don’t want to maintain them • Don’t know what to test • Edge cases are hard to find • Still end up with bugs no matter how many I write
  2. MBT fixes the problems I’m having • Hard to find

    time to write good tests • Avoid writing tests because I don’t want to maintain them • Don’t know what to test • Edge cases are hard to find • Still end up with bugs no matter how many I write ✅ ✅ ✅ ✅
  3. Step one: create an abstract model • Markov chains •

    Theorem proving • Finite state machines • Statecharts
  4. Machine-friendly formats stateDiagram [*] --> Sleeping Sleeping --> Idle :

    Wake up Idle --> Sleeping : Bored Idle --> Eating : Start eating Eating --> Idle : Done eating Idle --> Zoomies : ??? Zoomies --> Sleeping : Tired https://mermaid-js.github.io/mermaid/#/stateDiagram
  5. Step two: fill in actions and assertions • Tell the

    test executor how to figure out if it’s in the right state • Write code to perform the actions
  6. Step three: generate the tests • Generate paths: • Shortest

    paths from start to end • Random choice of action • Weighted choice of action (Dijkstra’s algorithm) • Define stop conditions • 100% node/edge coverage • Number of iterations • Test duration • Never
  7. Zero Press second button Running Stopped Press second button Press

    main button Press main button Lap Press second button Press main button
  8. Challenges with model-based testing • Learning curve – it’s a

    new approach for most • Hard to find tools • Can be hard to get the model right • When you’ve found a bug, it’ll keep popping up until it’s fixed
  9. Tools • NModel • Spec Explorer • GraphWalker graphwalker.github.io •

    AltWalker altom.gitlab.io/altwalker/altwalker • XState xstate.js.org
  10. Benefits of model-based testing • Better understanding of your app,

    or part of your app • Quicker to write tests, because you don’t • Easy to make changes • Tests won’t break because of refactoring • Better coverage and finding edge cases