SQLite compilation not copied to output folder for unit testing

Problem: The SQLite assembly referenced by my DAL assembly is not copied to the output folder when performing unit tests (the Copy Local option is set to true ).

I am working on a .NET application in VS2008, with NHibernate and SQLite in my DAL. Data access is open through the IRepository interface (factory repository) for other layers, so there is no need to reference NHibernate or System.Data.SQLite assemblies in other layers.

For unit testing, there is a public factory method (also in my DAL) that creates an in-memory SQLite session and creates a new implementation of IRepository. This is also done in order to avoid using the shared SQLite configuration in memory for all assemblies that need it, and to avoid referencing these internal DAL assemblies.

The problem is when I run unit tests that are in a separate project - if I do not add System.Data.SQLite as a reference to the unit test project, it is not copied to TestResults ... \ Out (although this project refers to my DAL project, which refers to System.Data.SQLite , which has the local Copy property set to true ), so the tests fail when setting up NHibernate. If I add a link to my test project, then it will be copied, and unit tests will work.

What am I doing wrong?

[Update]

I seem to have found the answer here: TFS UnitTesting does not deploy a local assembly to test dir on the assembly server . If I add a reference to this type with some static method in my DAL, it will be automatically copied when I reference the DAL assembly in my tests. This sounds like a hack, but IMHO is a cleaner solution than a stand-alone script, as it creates a β€œreal” dependency.

It also seems to be copied if I add the SQLite assembly as an additional deployment item to my test run configuration (LocalTestRun.testrunconfig file).

Thanks for your quick answers!

+7
unit-testing nhibernate system.data.sqlite
source share
2 answers

Your DAL project references the System.Data.SQLite assembly, but this does not mean that it will be copied to the output folder of the test project, especially if it is loaded using NHibernate reflection. Most likely, if you look at a compiled DAL assembly with a reflector, it will not even get into the collection list, since it is not used directly by the code. You have already found a solution by specifying it in the unit test project.

+6
source share

You can use the Post-build step to manually copy the dll to the output folder.

+1
source share

All Articles