Tag: NUnit

specflow

Parallel execution with Specflow 2.0 + NUnit + Selenium

In the last post we discussed how to work with Specflow 2.0 parallel execution, in this post we will discuss how to run Multiple tests in parallel in multiple browser same time using Specflow + NUnit + Selenium.

Problem with Selenium WebDriver object while running Specflow test in Parallel

Since we will be using selenium webdriver object in many Specflow step definitions and while running tests in parallel, we will encounter NullReferenceException , in order to resolve the problem, we need to use two important techniques

  • Context injection (dependency injection)
  • IOC Container

IOC Container

  • In software engineering, inversion of control (IoC) is a design principle in which custom-written portions of a computer program receive the flow of control from a generic framework.
  • A software architecture with this design inverts control as compared to traditional procedural programming: in traditional programming, the custom code that expresses the purpose of the program calls into reusable libraries to take care of generic tasks, but with inversion of control, it is the framework that calls into the custom, or task-specific, code.

-Source : Wikipedia

So how code looks like for IOC Container?

Here is the complete source code in GitHub https://github.com/executeautomation/SpecflowSeleniumParallel

Here are the complete videos of the above discussion

Video 1

Video 2

Thanks for reading the post and watching the video!!!

Please leave your comments and let me know if there is anything I should update in this post.

Thanks,
Karthik KK

specflow

Running Specflow test in Parallel using Specflow 2.0 and NUnit 3.x

In this post we will discuss one of the cool new feature introduced by Specflow 2.0, which is Parallel execution support out-of-box along with NUnit 3.x.

Does NUnit 3.x support parallel execution?

Yes it does, NUnit parallel execution support is discussed in greater details in Selenium automation with C# video series of ExecuteAutomation youtube channel

Parallel execution consideration

In order to achieve parallel test execution, there are some important consideration needed to be taken care before you ensure your test runs properly

Parallel execution with memory isolation (AppDomain)

  • Ensure your test code executing the application is not depends on static states (e.g. external cache, databases etc), if so then
  • This can be achieved by isolating test into AppDomain, this ensures that every test execution thread is hosted in a separate AppDomain and that each thread’s memory

Parallel execution without memory isolation (AppDomain)

  • If your tests do not depend on any static states (ie. do not store any test-specific information in static fields), you can run the tests in parallel without AppDomain isolation

What’s the code change in existing specflow code ?

It’s fairly very simple, just one line of additional change in AssemblyInfo.cs file and you are good to go and the change is this

Here is the complete video of the above discussion

Thanks for reading the post and watching the video!!!

Please leave your comments and let me know if there is anything I should update in this post.

Thanks,
Karthik KK

apitestinglogo

Introduction to API and Database Testing with Specflow and C#

In this post we will discuss about API and database testing with Specflow and C#.

API

API (Application Program Interface) is a set of routines, protocols, and tools for building software and applications.

API Types

Well, Web service is one of the types of API, but as already said, API is a set of routines, rules and protocol used to build software application

As that said, API can be

  • Web Service
    • Local IIS service
    • Remote web service
    • Cloud web service
  • Windows Service
  • Library
    • Selenium
    • Nunit etc
  • Protocols

Testing API

Testing of API can be done with different tools like

  • SOAP UI
  • Test Complete
  • Ranorex
  • WCF Client (Visual Studio)
  • Fiddler
  • Postman etc

Tool we are going to use for API and database testing

We will be using Visual studio + Specflow + C#

Here is the complete video of the above discussion

Thanks for reading the post and watching the video!!!

Please leave your comments and let me know if there is anything I should update in this post.

Thanks,
Karthik KK

seleniumwithC#

Using NUnit with Selenium C#

In this part we will use NUnit framework with Selenium C# in Visual Studio to execute multiple test methods along with many other features like

  • Initializing the Test method – Before execution
  • Cleaning up the Test method — After execution

NUnit will also give us many other assertion features which will be helpful while trying to assert two objects types, some of the methods are shown below

Splitting our code

In this post, we are going to split the code discussed in our last post to three different methods like

  • Initialize() — Setup
  • ExecuteTest() – Test
  • CleanUp – Teardown

Read more

TDD or BDD Style testing with Fluent Assertions

Fluent Assertions is a set of .Net extension methods that allow you to more naturally specify the expected outcome of a TDD or BDD-style test.

It runs on following frameworks

  • .Net 3.5,4.0 and 4.5
  • Windows store for Windows 8
  • Silverlight 4 and 5
  • Windows Phone 7.5 and 8

It also supports many unit test frameworks like

  • MSTEST
  • NUnit
  • XUnit
  • Gallio etc

Read more