Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium, Nunit Best Practices? [closed]

Tags:

selenium

nunit

I would like to learn more about how to use Selenium IDE and RC for creating good automation tests. Is there anybody who is interested in sharing info. or discussing this? Especially for things like:

1) What's a good way to organize the UI tests? Right now I am executing these tests thru NUnit and that executes the tests in the order of their alphabetical names. Is there a better way. (I am writing the selenium scripts in C# and not java)

2) How are the results logged?

3) Modularizing the Selenium RC tests? I am having a problem here. Since I am executing my tests thru NUnit, the only way I could figure was to give IDs to the tests so that they get run in the right order. Also I am having to write all my tests one after the other in the textfixture class. Again is there a better way? I tried creating additional files but when I create tests there and select them to run in NUnit, it looks like the selenium server doesn't even get started.

4) What are the best practices for automation testing? Any pointers to any sites/books/ etc.?

These might seem very simple things but I've spent weeks trying to come up with better ways, so if somebody is willing to offer suggestions or input I'll really appreciate it!

Thanks!

like image 717
Saavik Avatar asked Oct 20 '10 21:10

Saavik


People also ask

Which framework is best for Selenium C#?

In order to use Selenium WebDriver with C#, you need to install Visual Studio. NUnit is the Unit Testing framework supported by Visual Studio and Selenium webdriver. We need to install NUnit Framework and NUnit Test Adapter onto Visual Studio inorder to use it.

What is difference between NUnit and Testng?

NUnit was Initially ported from JUnit. Tests can be run from a console runner, within Visual Studio through a Test Adapter or through 3rd party runners. Tests can be run in parallel and has Strong support for data driven tests. Unit supports multiple platforms including .

What is TestFixture NUnit?

The [TestFixture] attribute denotes a class that contains unit tests. The [Test] attribute indicates a method is a test method. Save this file and execute the dotnet test command to build the tests and the class library and run the tests. The NUnit test runner contains the program entry point to run your tests.

What is NUnit in Selenium?

NUnit is a unit-test framework designed for all the . NET languages. It is written in C# and built to use many of the . NET language features.


3 Answers

I have answered each of the questions for you below.

  1. Tests shouldn't matter about the order that they run in. If you start worrying about that you are going to start introducing flakiness of tests. If you have to login with each test do so, if you need to register a number of users during your tests do so. Tests should always be able to run on their own.

  2. Nunit logs its results in a XML file. This will have a list of the passes and fails and is normally rendered in a pretty fashion by nearly all Continuous

  3. See my answer for Best Practices for modularizing Selenium RC test scripts

    • Tests should always have a known starting point. In the context of Selenium this could mean opening a certain page to start a workflow.
    • Tests should not have to rely on any other tests to run. If a test is going to add something do not have a separate test to delete it. This is to ensure that if something goes wrong in one test it will not mean you have a lot of unnecessary failures to check.
    • Tests should only test one thing at a time.
    • Tests should clean up after themselves.
like image 113
AutomatedTester Avatar answered Dec 19 '22 22:12

AutomatedTester


If your desires is to use Selenium then I can suggest instead use the TestPlan front-end instead of another language. In additional to a domain specific language it offers nice test case management. You can organize your tests into a nice hierarchy and it will execute all of them and report the results.

It takes care of a lot of details of launching Selenium and smooths over many difficulties in the RC API.

like image 23
edA-qa mort-ora-y Avatar answered Dec 19 '22 22:12

edA-qa mort-ora-y


I've just went through this. In terms of modularizing and useful tools. I think it's really important to think more about building an agile, well maintained automated ui testing framework than simply modularizing selenium RC scripts. Selenium 2: Testing Tools Begginner's Guide was a great start for idea how to start building a good testing framework. I had MUCH success with the (Page Object pattern)[https://code.google.com/p/selenium/wiki/PageObjects] after failing 2-3 times getting an automated testing framework going. In terms of proccess, I found it best to start by writing code (you are writing tests, so it should be pretty easy to test), but aggressively refactoring using good OOP as patterns and structures begin to build up. I'd also reccommend How Google Tests Software for motivation of Software QA in general, good testing practices on an organizational level, and when and when not to use automation.

like image 33
craastad Avatar answered Dec 19 '22 23:12

craastad