Skip to content

Unit testing with Sysl

Marcelo Cantos edited this page Jan 10, 2019 · 1 revision

Some early thoughts on using Sysl to define unit tests. Pay no attention to the syntax. It will probably be quite different.

Backend1:
    GET /txs/{crn<:string}:
        return <: set of Tx

Backend2:
    FetchTrans(custid<:string):
        return <: set of Tx

TransactionService:
    GET /transactions/{crn<:string}:
        loop:
            Backend1 <- GET /tx
        Backend2 <- FetchTrans
        return <: set of Transaction
        @testing = {:
            mocks: {
                "Backend1 <- GET /tx": [
                    {crn: 1, return: [234, 345]},
                    {error: 404},
                ]
                "Backend2 <- FetchTrans": [
                    {crn: 1, return: [123, 234]},
                    {crn: 2, return: [789]},
                ],
            },
            scenarios: [
                {crn: 1, return: [123, 234, 345]},
                {crn: 2, return: [789]},
            ],
        }
Clone this wiki locally