Does Microsoft.Silverlight.Testing have an execution order?
I'm trying to perform 开发者_StackOverflow中文版two methods marked [TestMethod]
in an order
First: Login
Second: GetUser
But MsTest chooses the Second
to be first.
Is there a a way to set order of execution of methods marked [TestMethod]
?
Ordering your tests like this is bad design. Most unit testing frameworks won't let you order your tests for this very reason. It sounds like you should be organising your tests like this:
Test 1: Test that a user can log in.
Test 2: Fake a logged in user, make sure that GetUser returns that faked user.
You should make sure your system is designed to allow this kind of testing (faking/mocking out of parts for tests). Otherwise you will end up with unmaintainable tests that will all break when something core does.
Think of it this way: in your second test, you aren't testing the login process, so why should the test break if login is broken? It shouldn't, so you need to make sure you can remove the dependency on the real login process, and instead use some method of setting up a user as logged in that cannot fail.
精彩评论