I am attempting to unit test a Portable Class Library that I've created and I want to make sure it's being tested with the same framework subset that it targets.
Per the Visual Studio ALM + Team Foundation Server blog, the MSTest unit test framework was converted to a PCL in Visual Studio 2012 RC; however, I am unable to create a portable class library and then reference the MSTest framework in VS2012 RTM.
Microsoft.VisualStudio.QualityTools.UnitTestFramework
yields a reference not found build error.C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\ReferenceAssemblies\v4.0\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
yields a build warning saying the UnitTestFramework assembly references an incompatible mscorlib
version.I did find (thanks to an early answer) that there is a project type Unit Test Library (Windows Store apps)
that references a different MSTest assembly at C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0\ExtensionSDKs\MSTestFramework\11.0\References\CommonConfiguration\neutral\Microsoft.VisualStudio.TestPlatform.UnitTestFramework.dll
. This project type creates a small no-UI Windows Store app... complete with manifest and everything. It also doesn't allow me to specify which frameworks I'm targeting - it appears to be only for Windows Store apps.
Under the potentially faulty assumption that I should be testing my Portable Class Library projects with unit test assemblies that target the same framework subset as the library-under-test...
How do I create a unit test assembly for a .NET Portable Class Library?
(I am open to other frameworks that also target PCL, I'm just currently unaware of other solutions besides MSTest that have taken this into account.)
Test the Release version of the libraryIn the Visual Studio toolbar, change the build configuration from Debug to Release. In Solution Explorer, right-click the StringLibrary project and select Build from the context menu to recompile the library. Run the unit tests by choosing Test Run > All Tests from the menu bar.
To get started, select a method, a type, or a namespace in the code editor in the project you want to test, right-click, and then choose Create Unit Tests. The Create Unit Tests dialog opens where you can configure how you want the tests to be created.
xUnit now has support for PCL unit testing; http://xunit.github.io/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With