1

I want to write the automation suite for windows services. Some of these services updates the data in database. So my test cases would be to check the current state of the DB, run the windows service and verify the changes in the DB(SQL Server).

What tools would be best option for performing this kind of testing. It will be more helpful if this tool can integrate with testNG or jUnit, and have a database connectivity option with SQL server as well.

Visual studio is obviously an answer, but just want to know if there are some tools available for this particular case.

1

According to my understanding you can use selenium with testNG or Nunit or MStest. As you mention your scenario will be :

1).check the current state of the DB To do that in selenium write a test method to open a SQL connection to the desired server and check the status or check the values at the table and save it as a string type variable.

2).Run the windows service : This is simple to invoke a windows service thru the c# code. http://www.csharp-examples.net/restart-windows-service/

3).Verify the changes in the DB: To perform this again write a method to open a SQL connection to the desired server and check the new status or check the new values at the table and save it in another string variable.

At last compare the 1st string value and 2nd string value using an assert commend. DONE.

1

Visual Studio itself is an IDE, an Integrated Development Environment - not a tool for interacting with databases. However, there are .NET CLR (Common Language Runtime) libraries for programmatic DB access.

I recommend, however, that you start with the asking the developers to create product hooks for you to use to interact with the database. This is likely to be safer than interacting with it directly with your tests. I'm pretty decent with programmatic DB access and still prefer to do it, when testing, through product hooks that are disabled in production. Product hooks definitely will get wrapped in tests and verified for consistent, well-understood behavior (unless the team is very lax). Test libraries, on the other hand, tend to get less care and are more likely to have bugs and unexpected side effects. Also, it simplifies how to manage authentication, as the product already authenticates for DB access.

Barring that, see how the developers and the product code interface with the databases. They may already have some great tools that simplify DB access compared to the libraries you would normally use, or they may have tools that enforce certain rules around how you access the DB that you need to use.

If that fails, you probably want to look at the database access classes in the CLR: MSDN's ADO .NET with SQL Server page is a good place to start. The MSDN documentation on LINQ to SQL, in particular, will contain the bulk of what you need to know.

If you go this route and are not familiar with database access code, I strongly recommend getting both test design reviews and code reviews from the product developers. There are often security implications around how the tests handle database authentication, and database interactions can have messy and long-lasting impacts on test environments.

  • 1
    IDE, an Integrated Development Environment – Jalal Dec 27 '17 at 7:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.