I'm reading few books and articles regarding unit testing and all of the show simple examples. My first goal is to check if user can login. I'm using MVC4 with Azure. If I understand correctly, tests are performed on blank database. How can for a test insert
one valid user and then test login with it? I'm using Default Membership. Also what is the best way to test it? All examples show how I call controller and pass values to action, but is this the right way? Shouldn I write a test which goes to website, populates
form and submits?
I'm really confused how to start here. I understand tests and TDD, but I dont find any good examples for more complex projects.
You're not talking about unit testing -- you're talking about integration testing. Integration testing is actually running the app, interacting with the UI and running the code such that it updates the DB... since you're testing the system integrated with
all the parts.
Moq is used when you're doing unit testing. Integration testing is just the normal setup of your application/database/whatever but perhaps seeded with test data.
ErolFoo
Member
17 Points
27 Posts
Unit testing user interaction
Apr 29, 2012 12:17 PM|LINK
Hello
I'm reading few books and articles regarding unit testing and all of the show simple examples. My first goal is to check if user can login. I'm using MVC4 with Azure. If I understand correctly, tests are performed on blank database. How can for a test insert one valid user and then test login with it? I'm using Default Membership. Also what is the best way to test it? All examples show how I call controller and pass values to action, but is this the right way? Shouldn I write a test which goes to website, populates form and submits?
I'm really confused how to start here. I understand tests and TDD, but I dont find any good examples for more complex projects.
BrockAllen
All-Star
27434 Points
4891 Posts
MVP
Re: Unit testing user interaction
Apr 29, 2012 02:24 PM|LINK
You're not talking about unit testing -- you're talking about integration testing. Integration testing is actually running the app, interacting with the UI and running the code such that it updates the DB... since you're testing the system integrated with all the parts.
Integration testing can be manual, but many people also automate it with tools like Selenium, VS' Coded UI Test or WatiN.
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
ErolFoo
Member
17 Points
27 Posts
Re: Unit testing user interaction
Apr 29, 2012 08:31 PM|LINK
I see. Right now I'm testing Moq and I'm again confused. How can I setup testing enviroment? So database, users etc...
BrockAllen
All-Star
27434 Points
4891 Posts
MVP
Re: Unit testing user interaction
Apr 29, 2012 08:35 PM|LINK
Moq is used when you're doing unit testing. Integration testing is just the normal setup of your application/database/whatever but perhaps seeded with test data.
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/