asp.net - Unit Test - User Account -
ASP.NET App in Visual Studio 2008
I have valid login for the test (in) web app I have a validation (user, pass) boolean method, empty case and invalid password tests are working properly.
My question is how to check a valid login I have accounts that are valid for web apps, but I think hardcoding is not the best solution in the username and password.
I'm thinking that I can: Allow the user to use the web app to create a test user, my test can be run, remove testuser
Are you trying to test here?
that:
- Passing will not be logged in user in wrong user name and / or password?
- Will the user log in with the correct username and / or passwords?
- Is this an account actually active directory? What will he prove? Has your IT administrator done his job?
Remember that you should not emphasize the facts, you should emphasize behavior. So instead of trying to verify that a particular account is in the ad, verify that when the correct username and password are given, your code behaves as expected, and when the wrong user name or password is given , Then it behaves as expected, and you should try doing this without including Active Directory.
In the first two cases above, there are several pieces in it:
- The code that takes in the username and password
- that username and Trying to detect an existing account with the password
- The code that is "Logged in" is actually
- "Incorrect username or" password "error < / Li>
So are you checking that your database works? Or does your code check validity ?
I will duplicate the code that is retrieving an existing account and it will have to answer "account data here" in a unit test and "no matching account" To do that, your login code responds properly, either logs in user, or answers with an error, and then insists on it.
Note that You have a habit at some point Preliminary Integration Testing also, because you want to make sure that your code works properly on Active Directory, but you should check that behavior as much as possible without including the Active Directory, it will make your tests more readable ( Everything is in one place), more efficiently (no need to create new test data to enter Active Directory), More reliable (no wonder that when someone has messed up in an Active Directory, the network is flaky, the user has been removed, the software has been upgraded so that it can be responded differently, etc.) .
I've seen a lot of "unit tests" fail due to external dependencies, and I suggest trying to minimize them as little as possible, ideally someone Not even For your unit test
Comments
Post a Comment