NUnit retry dynamic attribute

Viewed 2528

Hello I want to pass the number of retries dynamically from app.config value.

The app.config has the following line:

<add key="retryTest" value="3"/>

And I have defined this variable:

public static readonly int numberOfRetries = int.Parse(ConfigurationManager.AppSettings["retryTest"]);

Finally I would like to pass that variable as a parameter to Retry NUnit attribute:

[Test, Retry(numberOfRetries)]
public void Test()
{
    //.... 
}

But I get the following error:

"An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type"

How can I dynamically pass that value?

2 Answers
Related