Search Results for

    Show / Hide Table of Contents

    Sequential

    SequentialAttribute tells NUnit to generate test cases by matching parameter values by index rather than creating additional combinations.

    Usage

    This is a parameterless attribute that can only be applied to test methods.

    [Sequential]
    

    Applies To

    Test Methods Test Fixtures (Classes) Assembly
    ✅ ❌ ❌
    Note

    If parameter data is provided by multiple attributes, the order in which NUnit uses the data items is not guaranteed. However, it can be expected to remain constant for a given runtime and operating system. For best results with SequentialAttribute use only one data attribute on each parameter.

    Example

    The following test is executed three times.

    [Test]
    [Sequential]
    public void MyTest(
        [Values(1, 2, 3)] int x,
        [Values("A", "B")] string s)
    {
        Assert.That(x, Is.GreaterThan(0));
        Assert.That(s is null || s.Length > 0);
    }
    

    MyTest is called three times, as follows:

    MyTest(1, "A")
    MyTest(2, "B")
    MyTest(3, null)
    

    Notes

    1. Sequential pairs values from each parameter by position (index 0 with index 0, and so on).
    2. If parameter data lengths differ, missing entries are filled using the default value for that parameter type.
    3. Prefer one data-providing attribute per parameter when using Sequential to avoid ordering ambiguities.

    See Also

    • Combinatorial Attribute
    • Pairwise Attribute
    • Values Attribute
    • Edit this page
    In this article
    Back to top Generated by DocFX | Copyright (c) 2018- The NUnit Project - Licensed under CC BY-NC-SA 4.0