Cached Value

When you develop tests, you don't have to restart the whole flow from the beginning.Imagine you have a multistep test that includes running Command Line tool and then validating REST API response, and then opening a browser to assert UI values.Cache long steps results like created entities ids to speed up tests development.In the example below, you create first scenario that runs a heavy command line tool that generates an id. We then cache the value and you can write a second scenario and keep re-running it, without the need to re-run the first one. import static org.testingisdocumenting.webtau.WebTauGroovyDsl.* def createdId = cache.value("cli-heavy-created-id") // declare cached value with distinct id scenario("heavy setup operation") { def cliResult = cli.run("scripts/cli-heavy-process") // long running process that you don't want to re-run as you write your tests createdId.set(cliResult.extractFromOutputByRegexp("id=(\\S+)")) // caching the extracted id from CLI run } scenario("using previous setup id even after restart") { def id = createdId.get() // using cached value from previous test run. value will be preserved between restarts and re-compile http.get("/resource/${id}") { message.should == "hello" } } Note: Use groovy-standalone-runner/selective-run Selective Run or REPL/test-runs REPL mode to run one scenario at a time.

Cached Value With Expiration

Use get value with expiration time for scenarios like auth token def token = cache.get(authTokenKey, 60_000, () -> generateAuthToken())

FS Path type

file-system/introduction File System module return values of type Path . WebTau stores them as String . To retrieve as Path use import static org.testingisdocumenting.webtau.WebTauGroovyDsl.* def deployDirCache = cache.value("deploy-dir") scenario("caching of path value") { def path = fs.tempDir("my-dir") deployDirCache.set(path) } scenario("accessing path value") { def deployDir = deployDirCache.getAsPath() fs.writeText(deployDir.resolve("file.txt"), "hello") }

Presence Check

Use inside utilities methods to check if a cache value was set. def prevGenerated = cache.value("zip-unpacked-path") // ... if (!prevGenerated.exists()) { // recreate content } Avoid: using cache check inside test methods to keep them clean