Is there any solution to the slowness of the first NUnit test when using Entity Framework 4.1 ?
I'm finding it takes about 10 seconds for the first test, the rest of my tests are running in 0.01 seconds (according to Resharper Show Time option)
If I run the tests using the NUnit GUI, again first test takes 10 seconds, but if I re-run the entire set of tests runs in less than 0.5 second ... until I re-compile the solution
I've also got a NUnit tests of a WCF service hosted in IIS, which calls EF, and the first one finishes in about 3 seconds. Then if I re-run tests, it's down to 1 second and, as expected, on recompile the first time is back to 3 seconds.
But the original NUnit tests, which are against a class library with methods calling EF, are always around the 10 second mark, i.e. no decrease in time
Ok, I get that IIS is doing "something" [what?], but in both cases I'm using NUnit to do the calls ... why is one 10+ seconds for first call, the other is 3 seconds and then 1 second on subsequent calls ??
And to really confuse me, I wrote a simple console app that calls one of the EF using methods in the class being tested, and it manages to complete in 1 second.
UPDATE ... the same tests re-written as MSTest tests finish the first test in about 3.5 seconds, which is comparable to the first test run in the NUnit GUI runner, so the issue seems to be the Resharper test runner for NUnit in Visual Studio
UPDATE 2 ... yes, the issue does seem to be the Resharper test runner. TestDriven.NET and Visual Nunit 2010 both are quicker.
UPDATE 3 ... and it's now logged with JetBrains as an issue