diff --git a/Docs/UnitTests.md b/Docs/UnitTests.md new file mode 100644 index 00000000..df582e4a --- /dev/null +++ b/Docs/UnitTests.md @@ -0,0 +1,27 @@ +Rainmeter uses the [Visual Studio Native Unit Testing framework](http://msdn.microsoft.com/en-us/library/hh598953.aspx) for unit testing. + + +### General notes + +All unit test files should have the `$(ExcludeTests)` property set. The easiest way to ensure this is to manually edit the `ClCompile` entry of the project .vcxproj file. Make sure it looks something like this: + + + $(ExcludeTests) + + +When building within Visual Studio, the macro `$(ExcludeTests)` evaluates to `false` (i.e. the test files are **not** excluded). When building using Build.bat, it evaluates to `true`, and, consequently, the test files are excluded from the build. This is done in order to both reduce the actual build size and remove any kind of dependency on *Microsoft.VisualStudio.TestTools.CppUnitTestFramework.dll* (see below). + + +### Project type specific notes + +* Static library projects: + + Unit testing static library project requires the use of a separate DLL project. The static library project contains the actual code while the DLL project references the static library and includes the testing code. + + See `Common\Common.vcxproj` and `Common\Common_Test.vcxproj` for an example. + +* Dynamic library projects: + + A unit tested dynamic library project should contain both the actual code and the testing code. + + In addition, the `$(DelayLoadTestDLL)` macro should be included in the linker *Delay Loaded Dlls* option. The VS unit testing framework introduces a dependency on *Microsoft.VisualStudio.TestTools.CppUnitTestFramework.dll* for dynamic library projects, which means that omitting the `$(DelayLoadTestDLL)` macro will result in the dynamic library failing to load.