Giter Site home page Giter Site logo

csharp-specflow-selenium's Introduction

SpecFlow.Selenium

The goal of this project is to provide a good starting point for those looking to use SpecFlow and Selenium together. It is also intended to demonstrate how to implement design patterns in a test framework, where many test frameworks will violate many different principles like SOLID, Static Cling (this one is always the most common), and Explicit Dependencies.

Resources

TODO

  • .NET Framework
  • Mac setup
  • Build scripts (cake?)
  • Windows setup
  • .NET Standard
  • Visual Studio guide
  • Appium
  • Docker Selenium Grid execution

Setup - OSx

Download and install Visual Studio or JetBrains Rider

The required .net frameworks should download/install with your IDE of choice.

JetBrains Rider

No extra setup necessary

Visual Studio

Visual Studio needs a little extra configuration. Install these extensions;

  • xUnit.NET 2
  • SpecFlow

Install Homebrew

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

After installation:

$ brew doctor
Your system is ready to brew

Mono

$ brew install mono

Git

$ brew install git

Setup - Windows

Download and install Visual Studio or JetBrains Rider

The required .net frameworks should download/install with your IDE of choice.

JetBrains Rider

No extra setup necessary

Visual Studio

Visual Studio needs a little extra configuration. Install these extensions;

  • xUnit.NET 2
  • SpecFlow

Install Scoop (Windows Homebrew alternative)

Requirements

$ set-executionpolicy unrestricted -s cu

Install:

$ iex (new-object net.webclient).downloadstring('https://get.scoop.sh')

Git

$ scoop install git

Clone

$ git clone https://github.com/jukafah/csharp-specflow-selenium.git

IDE - Rider

As of writing this guide, generating the code-behind feature.cs files requires invoking the generator separately. Ken Bonny wrote a couple good articles for generating those and how to configure it with File Watcher. The guide will also walk you through associating the files together.

Generating SpecFlow Files in Rider

SpecFlow Steps Generation

Restore dependencies

$ nuget restore

From solution directory

$ mono "packages/SpecFlow.2.4.1/tools/specflow.exe" GenerateAll -p SpecFlow.Selenium/SpecFlow.Selenium.csproj

Import the generated feature.cs files to the same directory as your features.

Tests will now show in the Unit Tests / Test Explorer.

IDE - Visual Studio

TODO

Running Tests

You can run them in the Unit Test explorer of your chosen IDE or via command line

Build

$ msbuild

Run tests

$ mono "packages/xunit.runner.console.2.4.1/tools/net452/xunit.console.exe" SpecFlow.Selenium/bin/Debug/SpecFlow.Selenium.dll -xml ./TestResults/xunit.xml

Selection of browser is through an environment variable. Defaults to Chrome if unprovided.

$ BROWSER=firefox mono "packages/xunit.runner.console.2.4.1/tools/net452/xunit.console.exe" SpecFlow.Selenium/bin/Debug/SpecFlow.Selenium.dll -xml ./TestResults/xunit.xml

Then you can generate a nice html report via Pickles

$ mono "packages/Pickles.CommandLine.2.20.1/tools/pickles.exe" --feature-directory=SpecFlow.Selenium/Features/ --output-directory=./TestResults/pickles --link-results-file=./TestResults/xunit.xml --documentation-format=dhtml --test-results-format=xunit2

csharp-specflow-selenium's People

Contributors

jukafah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

csharp-specflow-selenium's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.