问题
I am putting together my teams development environment gearing up for our first big Xamarin.Forms project, involving a whole team from an Agile perspective.
I need to verify one assumption before I move forward... Unit Testing.
We plan on implementing a build infrastructure using TFS for Android and Windows Phone with Jenkins on OSX. Are there any special considerations we need to make when we create Unit Test projects?
Using NUnit
Can I just create class libraries that contain tests? Do they need to be PCLs? Will these work on an OSX CI box?
Any clarification would be greatly appreciated. I can't seem to find 1 definitive guide/primer on this subject.
Thanks in advance.
回答1:
We're successfully running a product using a similar setup ('cept we're building everything under OSX).
If all you're trying to test is your logic (and after all, isn't that what it's all about?), then you don't need to make the test assembly a PCL. This is good, because you can have the test assembly target the full .NET Framework and you get access to mocking frameworks (such as my personal favorite, Moq). Selecting NUnit (or XUnit) is important, as that allows you to run them under OSX.
If I might make a recommendation: you can also create integration tests with a framework such as SpecFlow: works a treat in Visual Studio (good design surface that lets you step through feature files in the debugger!), and the tests run just fine under OSX because they are really just N/XUnit classes. Couple that with Xamarin's new UI.Test framework, and you're cooking with gas.
来源:https://stackoverflow.com/questions/26550090/xamarin-cross-platform-unit-testing