Skip to content

How to generate multiple tests from one file? #279

Open
@matthiasbeyer

Description

@matthiasbeyer

Hi! Awesome crate, thanks for implementing it.

I wonder how I can generate multiple tests from one input file?


I have a scenario where I have a DSLish test script, which represents a test-fixture I can throw against my application via datatest-stable.
Think something like:

TestFixture:
    setup_app(name="foo")
    setup_client(name="c")
    connect_client(app="foo", name="c")
    client_send_command(name="c", command="process_data", data=[1,2,3])
    expect_client_received_reply(name="c", reply=6)

that is then run against my application as an end-to-end-test so to speak.

In reality the tests are much more complex of course, but that's all closed source, so I cannot share more here.

I am currently playing with the tera templating engine to generate multiple test-fixtures from one file:

{% for i in range(end=100) %}
TestFixture:
    setup_app(name="foo{i}")
    {% for j in range(end=100) %}
        setup_client(name="c{j}")
    {% endfor %}
    {% for j in range(end=100) %}
        connect_client(app="foo", name="c")
    {% endfor %}

...and so on, I hope you get the idea. But that would mean that I have multiple test fixtures that are generated per input file. Right now, I would run them with a single call to datatest-stable. That works.

What would be really nice though, would be to run them as individual calls to datatest-stable, so that I get (for the above example) 100 test runs, one for each fixture.


Maybe I am just "holding it wrong" and just don't see the obvious solution. But maybe not, then this is a "howto" or feature request issue 😉 .

I hope you have a great weekend!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions