We have an old asp.net application that has no unit tests, integration tests, component tests or UI/functional tests - surprise!
Now, we'd like to introduce some automated system testing that tests the functionality so that when something breaks in the app we immediately get notified!
For example, the user registration form where user can enter username and email address and register in the system.
It's too late/expensive to introduce unit tests (as the current design is not unit testable) so the most important thing now is writing Automated System Tests.
For example, we'd like to write a test in C# which opens the browser, enters the data to the text boxes, clicks on the Register button then our test checks whether the data is inserted into the database and whether a verification email is sent and at the end whether a proper message is shown to the user (of course this is only the main scenarios and there would be numerous special cases). Basically not testing isolated units but testing whether the whole process works!
So, what tool could I use to help me write such test and automating it?
What approach would you recommend to use?
I had a look at Selenium and Fitnesse but they don't seem to allow me write C# code to test database, etc. I looked at the SoapUI/LoadUI same issue. WatiN could possibly be used, not sure. any thoughts/recommendations are very much appreciated.
Hope the question is clear.
Many thanks,
Selenium absolutely does allow you to write C# code for system testing. First you would have a method to interact with the website, a second method to verify the database is correct. All within a single test app/class.
For the web interaction, you would use a WebDriver (taken from the Selenium API doc). Here's some example code of IWebDriver's interface. It interacts with google, but you can modify this to interact with your website.
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium;
class GoogleSuggest
{
static void Main(string[] args)
{
IWebDriver driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://www.google.com/");
IWebElement query = driver.FindElement(By.Name("q"));
query.SendKeys("Cheese");
System.Console.WriteLine("Page title is: " + driver.Title);
driver.Quit();
}
}
Then you would just implement another method that verifies the database entries are correct, using something like LinqToSql or other C# database API.
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