copypastedeveloper / given

Given is a bdd library made with the intent of wrapping common testing frameworks easily.
10 stars 2 forks source link

after delegate is not firing or not firing consistently #10

Open KarsonAlford opened 10 years ago

KarsonAlford commented 10 years ago

As NCrunch runs tests other tests that use dates are being affected by the india culture set in the before of other tests.

I have not ran this in TFS or R# yet.

    before initialize = () =>
    {
        Thread.CurrentThread.CurrentCulture = new CultureInfo("te-IN");
    };

    after clean_up = () =>
    {
        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
    };
copypastedeveloper commented 10 years ago

are you sure ncrunch isn't running your tests in parallel? also, just to be clear, each scenario runs the before and after statements once, not once per then. not sure if that's well documented.

KarsonAlford commented 10 years ago

I have attempted to turn off all NCrunch parallelism, and have not encounter this as often.

However, in the spirit of each test "running in isolation" or in this case each test "running in scenario isolation" we may want to consider enforcing scenario scoping of globals (such as thread context).

copypastedeveloper commented 10 years ago

I think that is a reasonable idea. I can add that as a feature request.