Why do I need to use NUnit with Selenium WebDriver?

I am just starting with Selenium using VS2012 and C #. I'm not sure if you need to use a separate testing environment such as NUnit or HtmlUnit. I tried out a Google search example that is available on the Internet in C # without using NUnit, and it worked fine.

So my question is in this question: why should I use NUnit with Selenium?

+4
source share
1 answer

You DO NOT NEED to use NUnit (or any other unit testing system) with Selenium if you do not want to. However, there may be times when you can use NUnit (or others) to take advantage of other things. For instance:

  • If you have existing unit tests, it keeps everything in one place. (If so, how do you want to organize things)
  • If you already use NUnit (or your preferred unit testing module) for unit tests, you can reuse the same test runner (e.g. NUnit console, NUnit GUI, ReSharper, etc.) that you use for NUnit, which means that you can run all your tests (NUnit and Selenium) with a single click / shortcut.
  • If you use continuous integration, it can run your selenium tests through an existing NUnit test runner (or whatever you prefer), which means that you do not need to configure a continuous integration server for selenium tests separately.

The above assumes that you already have unit tests. If you do not yet have unit tests or are only interested in Selenium tests (for example, we have a development team and a tester, we write unit tests, the tester writes Selenium tests and they run independently), then there is no need to add this additional layer .

Unit tests and selenium tests for different things. Unit tests usually look at a single unit of code at a time (although in practice I find that it often spills into adjacent units, especially if they are small and deterministic). Selenium views a web page (or series of pages) as a single test. Selenium tests need a system to combine many of its components to conduct a test. Therefore, it is tested at a higher level, since it checks several things at once. (for example, that the system can handle requests so that answers are returned, so that the answers contain the expected data, that clicking the buttons on the page does the right thing, go to the right page, etc.)

Ultimately, just because you can do something does not mean what you need. Running Selenium tests with a unit testing system is a convenience if you need to handle both. This may work for you, perhaps it is not.

+9
source

All Articles