linkrope / dunit

xUnit Testing Framework for D
Boost Software License 1.0
37 stars 9 forks source link

Support of SkipIf #31

Closed andre2007 closed 3 years ago

andre2007 commented 3 years ago

What do you think about supporting SkipIf

struct SkipIf
{
    bool delegate() b; // or just "bool b" for only allowing compile time arguments?
    string reason;
}

class GetDirectionalDerivativeTest
{
    mixin UnitTest;

    @Test
    @SkipIf(() => !platform.among("win32", "win64"), "Platform not supported")
    void test_get_directional_derivative()
    {
    }
}

Actually there is a DIP https://github.com/dlang/DIPs/blob/master/DIPs/DIP1033.md which would allow to write it like this:

@SkipIf(!platform.among("win32", "win64"), "Current platform not supported by this FMU")

andre2007 commented 3 years ago

Other use case: skipping a test based on environment variables like in this python example:

https://github.com/CATIA-Systems/FMPy/blob/a2c62367ebf57c9bcabd6f036636588f563502d4/tests/test_fmi3.py#L10

andre2007 commented 3 years ago

Fixed