New Posts New Posts RSS Feed: MS Test configuration w/ VS and ReSharper runners
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

MS Test configuration w/ VS and ReSharper runners

 Post Reply Post Reply
Author
WardBell View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 31-Mar-2009
Location: Emeryville, CA,
Posts: 338
Post Options Post Options   Quote WardBell Quote  Post ReplyReply Direct Link To This Post Topic: MS Test configuration w/ VS and ReSharper runners
    Posted: 31-Oct-2009 at 3:36pm
I use a variety of testing frameworks including MS Test.
 
While Visual Studio (VS) has a test runner, I use ReSharper (R#) and I love it.
 
Among its features is a Test Runner which runs test suites for many testing frameworks, including MS Test, right out of the box; you can add more testing frameworks by adding their plugins.
 
You have to configure things properly to get both the Visual Studio (VS) and R# (v.4.5) test runners to work with your DevForce application.
 
Some of this feels like voodoo but the steps are necessary because some of the items you need to make DevForce work are either not in your test project or won't be automatically picked up by the runners.
  1. Make sure you know which app.config defines access to your server model
  2. Configure VS Test Run Configuration properly
  3. For R#, that app.config must be a part of the test project and its "Copy Local" must be "Copy if newer" or "Copy always"
Step #2 is required for both the VS test runner and R# test runners.
 
"Properly" means that you have set up the testrunconfig file so the test runner can deploy certain files that it needs to run your tests. These "additional deployment files" are copied (along with your test project dll and every assembly it references) into the runner's own test execution directory.
 
At a minimum, you must add the app.config that describes your model.  If you don't, your tests will fail as soon as they instantiate an EntityManager; you'll get an exception complaining about not being able to find the app.config.
 
Here are example steps for setting up the testrunconfig file (they are also described in the Developers Guide):
  • From the VS menu: "Test | Edit Test Run Configurations | Local Test Run (localtestrun.testrunconfig)"
  • Choose the "Deployment" tab
  • Ensure "Enable deployment" is checked (it is by default)
  • Click "Add File"
  • Browse to the directory holding the app.config
  • Switch the option to look for "all files" so you can see it
  • Select it and click "Open"

If your test project doesn't reference your application's Entity Framework model (why should it?) and that Entity Framework model is in its own project (that's how I like to do it), then DevForce won't be able to talk to EF ... or the database. You'll need that EF dll for certain integration tests.

You'll use this same testrunconfig file to find and copy the EF Model dll(s) into the test execution directory.
  • Click "Add File",
  • Browse to your EF model DLL,
  • Select it and click "Open" to include it

You need IdeaBlade.EntityModel.Server.dll in order to access your data source. If your test project doesn't have a reference to it, you'll have to use "Add File" again to identify that dll so it can be copied into the directory where the tests are run.

Personally, I don't mind if my Test Project has a reference to IdeaBlade.EntityModel.Server.dll which means I won't have to add it to this deployment file list.
 
When you're done, the "Additional files ..." listbox might look something like:
<Solution Directory>\SomeProject\app.config
<Solution Directory>\Model.EF\bin\debug\Model.EF.dll
Click "Apply" and then "Close".
 
--

Step #3 is a requirement for the R# test runner; you can have done step #2 properly but omitting "Copy Local" will drive you crazy wondering why R# can't find the DevForce app.config file. 

While the app.config must be "a part" of the test project, the physical app.config does not have to be in the test project. You can link to it with a shortcut (same trick we use to link Silverlight class files to their physical files in .NET projects).
 
--
 
Your integration tests should now run and you will be able to reach the database.
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down