Giter Site home page Giter Site logo

rasouza1982 / betterspecs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from andrebaltieri/betterspecs

0.0 2.0 0.0 1.14 MB

BetterSpecs is the simple way to bring the power of spec to your tests. Based in xSpec (Like RSpec, and Jasmine) tools, BetterSpecs, improves tests experience on MSTest or NUnit tools.

C# 100.00%

betterspecs's Introduction

BetterSpecs alt tag

xSpec "is a great tool in the behavior-driven development (BDD) process of writing human readable specifications that direct and validate the development of your application" (betterspecs.org).

BetterSpecs is the simple way to bring the power of spec to your tests. Based in xSpec (Like RSpec, and Jasmine) tools, BetterSpecs, improves tests experience on xUnit tools.

๐Ÿ“ฆ install package

To install Betterspec in your MSTest project use this command:

PM> Install-Package BetterSpecs

๐Ÿ“ฆ using betterspecs

using BetterSpecs;

[TestClass]
public class SpecContextTests : SpecContext
{
  ...
}

describe

[TestMethod]
public void describe_speccontext_while_using_it()
{
    describe["when use SpecContext class"] = () =>
    {
        it["works very well"] = () => Assert.IsTrue(true);
    };
}

mixin contexts

[TestMethod]
public void describe_speccontext_while_using_it()
{
    context["when use SpecContext class"] = () =>
    {
        context["with two context"] = () =>
        {
            it["works very well"] = () => Assert.IsTrue(true);
        };
    };
}

using let

defer the instance creation

[Test]
public void describe_register_user()
{
    context["when create a user"] = () =>
    {
        User user = null;
        let.Add("user", () => 
        { 
          user = new User("[email protected]");
          return user;
        });
        
        it["is null"] = () => Assert.Null(user);
        it["is not null"] = () => Assert.AreEqual(user, let["user"]);
    };
}

output spec

When finished run tests, the output will be like this:

when use SpecContext class
with other internal context
    It works very well

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.