Memo (writeMemo, readMemo, clearMemo, memoTextAs, writeRunMemo, readRunMemo, clearRunMemo, runMemoTextAs, currentVariant)

in Japanese(日本語)

Pass values around. Every @Test runs as its own process, so a Swift variable does not carry over. There are two memos:

One fleetest run (one Run in the extension) is one run. A run profile that lists devices on several machines is still one run (the run memo is shared by all the machines).

Functions

function description
writeMemo(key, text) Appends text to the key's history (this test only).
readMemo(key) -> String Returns the last value written under the key in this test, or "" when there is none (not a failure; the step carries the note memo-key-not-found).
clearMemo() Clears the whole memo of this test.
element.memoTextAs(key) Writes the grabbed element's text (the first non-empty of label and value) and returns the element. Fails if no element was grabbed.
string.memoTextAs(key) Writes the string and returns it.
writeRunMemo(key, text) Appends text to the key's history in the run memo.
readRunMemo(key) -> String Returns the last value written under the key in the run memo, or "" when there is none (not a failure; the step carries the note run-memo-key-not-found).
clearRunMemo() Clears the whole run memo.
element.runMemoTextAs(key) Writes the grabbed element's text to the run memo and returns the element. Fails if no element was grabbed.
string.runMemoTextAs(key) Writes the string to the run memo and returns it.
currentVariant The name of the run profile variant this scenario runs as (String?; nil in a run without variants). The run memo is shared by every variant, so put it in the key to keep values apart: writeRunMemo("cart-\(currentVariant ?? "base")", text).

Scope

The memo (writeMemo etc.)

The run memo (writeRunMemo etc.)

Example

import FTDSL

@RunHooks
class RunSetup {
    func beforeRun() {
        writeRunMemo("shop", data("[shop1].name"))
    }
}

@TestClass
class OrderFlow {
    @Test("the receipt shows the shop")
    func S0010() {
        scenario {
            scene(1, "Check") {
                expectation {
                    select("#receipt_shop").textIs(readRunMemo("shop"))
                }
            }
        }
    }

    @Test("the memo carries a value within one test")
    func S0020() {
        scenario {
            scene(1, "Remember") {
                action {
                    select("#order_no").memoTextAs("orderNo")
                }
            }
            scene(2, "Check") {
                expectation {
                    select("#receipt_order_no").textIs(readMemo("orderNo"))
                }
            }
        }
    }
}