typelevel / typelevel/scalacheck

Help with stateful testing

Open
#199 14 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
2k
Forks
393
Avg merge
6h 42m
Merged PRs (30d)
4

Description

Hi there,

What if I need to be able to use the result of run() of one Command to provide state that subsequent Command(s) can use?

A very simple example would be if you had an API with two methods; one returns a random number, and another API call requires you to pass that number back to retrieve some value. I'd like to add the random number retrieved in run() to the state, so that subsequent Command objects can check for its existence and run the retrieval Command against that particular number. In this case, since its a random number being returned, I cannot 'simulate' this in the test suite; I cannot use nextState(), since it does not have access to the result of run(). Is this on purpose, and if so am I just thinking about this all wrong?

The bigger picture is that running sequences of commands where a Command later in a sequence depends on the results of previous commands is something I'm having trouble understanding how to do; at least when the result of running a Command isn't something I can simulate, because I simply don't know whats going to be returned to me.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the stateful-testing API around Command.run and nextState, then trace how state is passed between sequential Commands. Define how a run() result could become state visible to later Commands and how that behavior could be tested; the issue is done when dependent sequences can use an unpredictable prior result.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
testing-qa
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.