All Projects → thomhurst → BDTest

thomhurst / BDTest

Licence: Apache-2.0 License
BDTest - A Testing Framework for .NET

Programming Languages

javascript
184084 projects - #8 most used programming language
C#
18002 projects
CSS
56736 projects
HTML
75241 projects
Batchfile
5799 projects

Projects that are alternatives of or similar to BDTest

Telegraf-Test
Telegraf Test - Simple Test ToolKit of Telegram Bots
Stars: ✭ 22 (-62.07%)
Mutual labels:  test, test-automation, tests
Cypress
Fast, easy and reliable testing for anything that runs in a browser.
Stars: ✭ 35,145 (+60494.83%)
Mutual labels:  test, test-automation, tests
Should.js
BDD style assertions for node.js -- test framework agnostic
Stars: ✭ 1,908 (+3189.66%)
Mutual labels:  tdd, test, tests
PixelTest
Fast, modern, simple iOS snapshot testing written purely in Swift.
Stars: ✭ 56 (-3.45%)
Mutual labels:  tdd, test, tests
arduino-ci-script
Bash script for continuous integration of Arduino projects
Stars: ✭ 25 (-56.9%)
Mutual labels:  test, test-automation, tests
mutode
Mutation testing for JavaScript and Node.js
Stars: ✭ 61 (+5.17%)
Mutual labels:  test, tests
playwright-test
Run unit tests with several runners or benchmark inside real browsers with playwright.
Stars: ✭ 81 (+39.66%)
Mutual labels:  test, tests
framework
Lightweight, open source and magic-free framework for testing solidity smart contracts.
Stars: ✭ 36 (-37.93%)
Mutual labels:  tdd, test
bdd-for-all
Flexible and easy to use library to enable your behavorial driven development (BDD) teams to easily collaborate while promoting automation, transparency and reporting.
Stars: ✭ 42 (-27.59%)
Mutual labels:  tdd, test-automation
verification-tests
Blackbox test suite for OpenShift.
Stars: ✭ 41 (-29.31%)
Mutual labels:  test-automation, tests
unittest expander
A library that provides flexible and easy-to-use tools to parameterize Python unit tests, especially those based on unittest.TestCase.
Stars: ✭ 12 (-79.31%)
Mutual labels:  test, tests
carina
Carina automation framework: Web, Mobile, API, DB etc testing...
Stars: ✭ 652 (+1024.14%)
Mutual labels:  test, test-automation
phpunit-injector
Injects services from a PSR-11 dependency injection container to PHPUnit test cases
Stars: ✭ 62 (+6.9%)
Mutual labels:  test, tests
jest-retry
Jest retry pattern for flaky E2E tests
Stars: ✭ 36 (-37.93%)
Mutual labels:  test, test-automation
xv
❌ ✔️ zero-config test runner for simple projects
Stars: ✭ 588 (+913.79%)
Mutual labels:  tdd, test
eat
Json based scenario testing tool(which can have test for functional and non-functional)
Stars: ✭ 41 (-29.31%)
Mutual labels:  test, test-automation
dojos
Alguns desafios para os participantes dos grupos de estudo
Stars: ✭ 33 (-43.1%)
Mutual labels:  test, tests
action-junit-report
Reports junit test results as GitHub Pull Request Check
Stars: ✭ 103 (+77.59%)
Mutual labels:  test, test-automation
7182
Curso 7182 - Refatorando para testes de unidade
Stars: ✭ 21 (-63.79%)
Mutual labels:  test, tests
estj
EstJ is my own test framework!
Stars: ✭ 13 (-77.59%)
Mutual labels:  tdd, tests

BDTest

A testing and reporting framework for .NET

nuget Codacy Badge CodeFactor Nuget

Support

If you like using BDTest, consider buying me a coffee.

Buy Me A Coffee

Wiki

Please view the wiki to see how to use BDTest and how to get setup: https://github.com/thomhurst/BDTest/wiki

What is it?

BDTest is a testing and reporting framework focusing on 'Behaviour Driven Testing' ideologies. It's a way to structure and run your tests so that:

  • They are clear, concise and easy to understand
  • They are easy to run and debug
  • They don't share state. They are independent, side-effect free and able to run in parallel, meaning faster and more stable tests!
  • They translate into business criteria and focus on how the system under test would be used by an end user and their behaviours
  • You have an easy way to see test results and share them with your team or business

BDTest can be used standalone, or alongside an existing test running framework. For best results, I recommend NUnit, and installing the BDTest.NUnit package alongside the core BDTest package.

Why?

I was originally inspired to build BDTest due to SpecFlow. My team at work used SpecFlow (as does much of the .NET based industry) for their tests when I joined, and upon using it, realised I really didn't enjoy using it and found it to be difficult to work with, finnicky and long-winded. It turned out, my team also really disliked it, so I thought I'd change things.

Think of BDTest as a pure code-based alternative to SpecFlow.

What's the benefit over SpecFlow?

  • Passing in more complicated arguments to tests. Enums, models, etc.
  • You get the benefit of separating steps into Given, When, Then. However you can use and re-use existing steps without redefining or attributing them as Given step, or a When step, etc.
  • No auto-generated code. All code is your code! So you shouldn't see any weirdness. This also means no extra weird compilation steps and bringing in specific test compilers/runners.
  • Easier to debug. Test has failed and thrown an exception? The stacktrace should take you straight to where it happened. No being taken to strange auto-generated classes that you don't care about!
  • Step into all your code. I used Rider as my IDE, which didn't support SpecFlow, so I couldn't step into my test methods. I had to do a painful Find All! Now as it's all code, I can step straight into my test methods.
  • No learning and maintaining separate Gherkin files!

But non-technical team members can write tests using SpecFlow

  • Does that EVER actually happen though?
  • They can only use the high level methods. Any new methods, a developer will still need to code the steps for them. If they can only use the high level methods, make the method names human readable, and they can still use them!

I need reports that translates to business acceptance criteria

  • BDTest does that!
  • BDTest produces you a clear, easy to understand report, showing what failed and what passed, with output and exceptions from tests automatically captured
  • Mark your classes and methods with [StoryText], [ScenarioText], and [StepText] attributes, providing the output you want, and your reports will produce clean text output
  • If you don't mark your methods with attributes, BDTest will automatically convert the method name to text (separating words by capitalisation or underscores)
  • If you use the report server, you can just send the relevant party a URL directly to your test report!

Where can I use it?

BDTest is written in .NET Standard, so you can use it in either .NET Framework or .NET Core

How do I get started?

View the wiki to see how to use BDTest and how to get setup: https://github.com/thomhurst/BDTest/wiki

Example Test

namespace BDTest.Example
{
    [Story(AsA = "BDTest author",
        IWant = "to show an example of how to use the framework",
        SoThat = "people can get set up easier")]
    public class ExampleTest : NUnitBDTestContext<MyTestContext>
    {
        // Context property is magically available, created by the `NUnitBDTestContext` base class. It's unique for each NUnit test!
        private AccountSteps AccountSteps => new AccountSteps(Context);
        private HttpAssertionsSteps HttpAssertions => new HttpAssertionsSteps(Context);
        
        [Test]
        [ScenarioText("Searching for a non-existing account number returns Not Found")]
        public async Task FindNonExistingAccountReturnsNotFound()
        {
            await When(() => AccountSteps.FindAccount(12345))
                .Then(() => HttpAssertions.TheHttpStatusCodeIs(HttpStatusCode.NotFound))
                .BDTestAsync();
        }
        
        [Test]
        [BugInformation("123456")]
        [ScenarioText("Can successfully create a new account")]
        public async Task CreateNewAccountSuccessfully()
        {
            await When(() => AccountSteps.CreateAnAccount())
                .Then(() => HttpAssertions.TheHttpStatusCodeIs(HttpStatusCode.OK))
                .BDTestAsync();
        }
    }
    
    public class AccountSteps
    {
        private MyTestContext _context;
        
        public class AccountSteps(MyTestContext context)
        {
            _context = context;
        }
        
        [StepText("I create an account")
        public async Task CreateAnAccount()
        {
            // ... Some code to create an account!
            // You can use all the information stored in your test context object that was passed into the constructor!
            // And store stuff for later use - Such as assertions!
            // e.g. 
            // var request = new HttpRequestMessage { Method = POST, Body = SomeBody, Uri = SomeUri };
            // _context.HttpResponse = await HttpHelper.SendAsync(request);
        }
        
        [StepText("I search for the account with the customer ID '{0}'")
        public async Task FindAccount(int customerId)
        {
            // ... Some code to find an account!
            // e.g. 
            // var request = new HttpRequestMessage { Method = GET, Uri = $"{SomeUri}/{customerId}" };
            // _context.HttpResponse = await HttpHelper.SendAsync(request);
        }
    }
    
    public class HttpAssertionsSteps
    {
        private MyTestContext _context;
        
        public class HttpAssertionsSteps(MyTestContext context)
        {
            _context = context;
        }
        
        [StepText("the HTTP status code is {0}")
        public async Task TheHttpStatusCodeIs(HttpStatusCode code)
        {
            // ... Some code to assert - Read data previously stored in your context object!
            // e.g.
            // Assert.That(_context.HttpResponse.StatusCode, Is.EqualTo(code));
        }
    }
}

Report Server Example Image

Report Server Example Image

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].