Code Monkey home page Code Monkey logo

nspec's Introduction

NSpec

NuGet Version and Downloads count Build status

NSpec is a BDD (Behavior Driven Development) testing framework of the xSpec (Context/Specification) flavor for .NET. NSpec is intended to drive development by specifying behavior within a declared context or scenario. NSpec is heavily inspired by RSpec and Mocha.

Documentation

See nspec.org for instructions on getting started and documentation.

Examples

See under examples/:

  • DotNetTestSample
    Sample solution showing how to setup a NSpec test project targeting .NET Core

  • NetFrameworkSample
    Sample solution showing how to setup a NSpec test project targeting .NET Framework

Also, there are a couple of projects under sln/test/Samples/ path, SampleSpecs and SampleSpecsFocus. Those are part of main NSpec solution, needed when testing NSpec itself, and contain several mixed examples of NSpec test classes.

Breaking changes

To check for potential breaking changes, see BREAKING-CHANGES.md.

Contributing

See contributing doc page.

License

MIT

Credits

NSpec is written by Matt Florence and Amir Rajan. It's shaped and benefited by hard work from our contributors.

nspec's People

Contributors

allonhadaya avatar amirrajan avatar benniecopeland avatar braincrumbz avatar doun avatar ericbock avatar etruong42 avatar franklinwise avatar giuseppepiscopo avatar jakubfijalkowski avatar jboarman avatar jspringer2020 avatar kina avatar malixsys avatar mattflo avatar midripps avatar mps avatar ot-matt-florence avatar raghur avatar steinblock avatar vpalivela avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nspec's Issues

Resharper file doesn't seem to allow Gherkin style naming

Hey Matt,

Loving your work!

Just being bugged by resharper - given_the_world_has_not_come_to_an_end(), etc all still come up with recommendations to rename, even after I've applied your team settings file. Any advice?

Thanks!

nspec.org seems to be broken

http://nspec.org

Returns a GitHub Pages error:

Site Disabled

Oh no! It looks like this Pages site has been disabled due to a misconfigured custom domain.

Are you the site owner? You can quickly fix this issue by updating the DNS record for your Pages site:

If you're using a subdomain (coolthing.example.com, www.example.com, etc.), make sure you have a CNAME record that points to your-username.github.io.
If you're not using a subdomain (example.com), make sure you have two A records set to the following IPs: 192.30.252.153 and 192.30.252.154
More detailed instructions for setting up a custom domain with GitHub pages are also available if you need more guidance.

You can find more information about these changes in our GitHub Pages legacy IP deprecation blog post. If you have any questions, please contact support.

Nested Contexts Not Applied When Closing Over a Local Variable

I have a simple stack with inherited contexts. The basic usage that is giving me trouble goes like this:

context stack.add 1
    stack.count.should_be(1)
    context stack.add 2
        stack.count.should_be(2)
        stack.peek().should_be(2)

Is this correct? I am getting different behavior where the base context is not being applied and the bottom/nested stack.peek() actually returns 2 but the count is 1.

I get the following result from running my specs:

=========== running spec: describe_Stack =====
"./packages/nspec.0.9.41/tools/NSpecRunner.exe" "StackSpec/bin/Debug/StackSpec.dll" "describe_Stack"

describe Stack
  given a new stack
    should be empty
    should have a count of 0
    Peeking should return null
    When an item has been pushed into the stack
      The count should have increased by 1
      The stack should not be empty
      Peeking should return the added value
      Popping the stack with one item
        Popping should make the stack empty
        Popping should make count 0
      When another item has been pushed into the stack
        The count should have increased by 1 - FAILED - Expected: 2, But was: 1
        Peeking should return the added value

**** FAILURES ****

nspec. describe Stack. given a new stack. When an item has been pushed into the stack. When another item has been pushed into the stack. The count should have increased by 1.
Expected: 2, But was: 1
at StackSpec.describe_Stack.<>c__DisplayClassd.<given_a_new_stack>b__b() in c:...\StackSpec\describe_Stack.cs:line 33

10 Examples, 1 Failed, 0 Pending

    public class describe_Stack : nspec
    {
        private void given_a_new_stack()
        {
            var stack = new Stack();
            it["should be empty"] = () => stack.IsEmpty.is_true();
            it["should have a count of 0"] = () => stack.Count.should_be(0);
            it["Peeking should return null"] = () => stack.Peek().should_be(null);
            context["When an item has been pushed into the stack"] =
                    () =>
                    {
                        stack.Push(5);
                        it["The count should have increased by 1"] = () => stack.Count.should_be(1);
                        it["The stack should not be empty"] = () => stack.IsEmpty.should_be_false();
                        it["Peeking should return the added value"] = () => stack.Peek().should_be(5);
                        context["Popping the stack with one item"] =
                                () =>
                                {
                                    stack.Pop();
                                    it["Popping should make the stack empty"] =
                                            () => stack.IsEmpty.should_be_true();
                                    it["Popping should make count 0"] =
                                            () => stack.Count.should_be( 0 );
                                };
                        context["When another item has been pushed into the stack"] =
                                () =>
                                {
                                    stack.Push(1);
                                    it["The count should have increased by 1"] = () => stack.Count.should_be(2);
                                    it["Peeking should return the added value"] = () => stack.Peek().should_be(1);
                                };
                    };
        }
    }

    public class Stack
    {
        List<object> _Items = new List<object>();
        public bool IsEmpty
        {
            get { return Count == 0; }
        }

        public int Count
        {
            get { return _Items.Count; }
        }

        public object Peek()
        {
            return IsEmpty ? null : _Items[_Items.Count -1];
        }

        public void Push( object value )
        {
            _Items.Add( value );
        }

        public object Pop()
        {
            var last = _Items[_Items.Count - 1];
            _Items.RemoveAt( _Items.Count -1 );
            return last;
        }
    }

NSpecRunner not pulling right class name

Morning,

When I run dotnet.watchr.rb in the background and save the file, the running spec seems to be grabbing "describe_My_Class" instead of "My_Class". If I rename the class to "describe_My_Class", the application trys to find "describe_describe_My_Class" My project is called "ABC.Test". Any idea on how I might be able to correct this?

Thanks for a great test framework....

James

NSpec doesn't handle strong-name signed unit test DLL

I have to strong-name sign my unit test DLL to friend it to a product DLL. After signing, there's an error, "Referenced assembly 'NSpec' does not have a strong name". I can disassemble and then sign/reassemble the NSpec DLL, but that's a hassle and other frameworks (xBehave.net/xUnit) work OOTB in the same situation. Perhaps NSpec can do what they're doing. I've seen them work with both signed and unsigned unit test DLLs.

Before_all & After_all

I am trying to write some specifications to test my DAL. I would like to create the database from my nhibernate configuration on the fly, run my tests, and then remove the database after the testing is complete. Although I could create and remove the DB after ever test, this slows things down considerably. It would be nice to have it set up before all the tests and removed after all the tests.

Let me know if there is already an existing way of doing this. Thanks!

expect with assertions

Currently, there is no (documented) way to expect an exception to be thrown, while also doing assertions, like check if a flag is reset in a finally block or the other usual disposable stuff.
One could work around that with some ugly try/catch logic in act, but it would be quite a mess.

NSpecRunner unable to pull in config file

I am loading a configuration file inside of my tests. When I run the tests using the debugger shim, the test passes and is able to successfully load the config file. However, when I run the tests using NSpecRunner, attempting to load that file throws an error. I've run the test using NUnit and ReSharper, both are able to run the debugger shim and successfully pull in the config file. The file is an nhibernate.config file.

IL merged nunit doesn't play nice with other versions of explicitly referenced nunits

This is a regression introduced somewhere between v66 and v68. It works fine on v66 but breaks on v68. If you have nspec and another version of nunit referenced in the same project. And you are using nspec assertions. Then running the nunit tests results in this error:

System.IO.FileLoadException : Could not load file or assembly 'nunit.framework, Version=2.5.7.10213, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' or one of its dependencies. The located assembly's manifest definition does not match
the assembly reference. (Exception from HRESULT: 0x80131040)
at NSpec.AssertionExtensions.Is(Object actual, Object expected)

also for reference the version of nunit that is referenced by the test project is 2.6.3

config files

Config files belonging to DLLs NSpec is executing are not handled properly and do not load peroperly. NUnit & MSTest, and other runners, do something (rename/copy) to make config files discoverable while running the test DLL under the test runner executable.

Documentation for how the lifecycle of before/each/all/act/it/after should work

It's not clear to me how the lifecycle of nspec tests goes. It seems like it should be possible to mix class level and delegate level before/act/it/after, but it doesn't work like I expect it to. I expect

  1. class level before_all
  2. class level before_each
  3. class level act_each
  4. each method in a class with an underscore
    1. delegate level before_all, within the method
      1. delegate level before (what is the difference between before, beforeAll and beforeEach??)
      2. delegate level before_each
      3. delegate level act
      4. it assertions
      5. delegate level after_each
    2. delegate level after_all
  5. class level after_each
  6. class level after_all

My context is that I'm writing outside-in API tests using OWIN+TestServer. I want to have a base class to take care of IoC, AutoFixture, NLog (I assert against logs in a memory-target), IoC container and TestServer. I think I want:

  • once-per-class
    • set up autofixture
    • set up logging
  • once per test method
    • once per context
      • set up container & poke in fakes where I want (I only want to fake away at my process boundaries)
      • set up TestServer with container

I've chosen to use xunit v2 as my debuggershim rather than nunit. I've chosen to use fields to hold my AutoFixture, Container and TestServer instances, on the assumption that I get a new instance of my whole class per test-method (which might be a wrong assumption). I have helper methods to create each item. I need those items to be available so that I can issue http requests to the app, having first substituted in fakes configured the way I need.

I've tried to write a spec to illustrate the combinations, which is below. I'm not sure I'm seeing what I'm expecting, to be honest. It would be nice to see a canonical diagram illustrating the lifecycle!

Are class fields the right thing to use, here? The examples on the home page illustrate that, but I'm guessing maybe doing that is the root of my issue - because I don't understand the lifecycle and what happens when.

If I can't use class fields, then I'll need to create helper methods to create each thing and return an instance that I can then use within my tests. But then I'm back to a world of duplicating setups and I seem to have lost most of the benefits that nspec brings regarding expressing behaviour concisely. I'm convinced I'm missing an ah-hah moment...?

Is there an illustration somewhere of how to use an auto-mocking container with nspec and nested contexts...?

Could the before/act/etc methods and delegates take and return a dynamic, that is the mutated state that they are responsible for doing, that is then fed through the pipeline so I can use that to assert against at the end...?

using XUnit;
using NLog;
using NLog.Targets;
using Shouldly;

    public class nspec_reminder_doc : nspec_base
    {
        public void when_greeting()
        {
//            it["should be ok"] = () => "ok".ShouldBe("ok");
//            it["should be silly"] = () => "silly".ShouldBe("silly");
        }

        public void before_all()
        {
            _output += "cl_before_all,";
        }

        public void before_each()
        {
            _output += "cl_before_each,";
        }

        public void act_each()
        {
            _output += "cl_act_each,";
        }

        public void after_each()
        {
            _output += "cl_after_each,";
        }

        public void after_all()
        {
            _output += "cl_after_all,";
        }

        private string _output = "";

        public void remind_lifecycle_class_level()
        {
            after = () => _output = "";
            it["class level should print"] = () =>
                _output.ShouldBe("cl_before_all,cl_before_each,cl_act_each,");
            it["should print 2ndly because it unwraps and then wraps"] = () =>
                _output.ShouldBe("cl_before_all,cl_before_each,cl_act_each,");
        }

        public void remind_lifecycle_both_class_level_and_delegate()
        {
            beforeAll = () => _output += "del_beforeAll,";
            beforeEach = () => _output += "del_beforeEach,";
            before = () => _output += "del_before,";
            it["mix class level and delegate level should print"] = () =>
                _output.ShouldBe("cl_before_all,cl_before_each,del_beforeAll,del_beforeEach,");
            it["2nd time mix class level and delegate level should print"] = () =>
                _output.ShouldBe("cl_before_all,cl_before_each,del_beforeAll,del_beforeEach,");
        }

        public void remind_lifecycle_with_context()
        {
            beforeAll = () => _output += "del_beforeAll,";
            beforeEach = () => _output += "del_beforeEach,";
            before = () => _output += "del_before,";
            context["1"] = () =>
            {
                beforeAll = () => _output += "1_del_beforeAll,";
                beforeEach = () => _output += "1_del_beforeEach,";
                before = () => _output += "1_del_before,";
                it["context 1 should print"] = () =>
                    _output.ShouldBe("cl_before_all,cl_before_each,cl_act_each,");
            };
            context["2"] = () =>
            {
                beforeAll = () => _output += "2_del_beforeAll,";
                beforeEach = () => _output += "2_del_beforeEach,";
                before = () => _output += "2_del_before,";
                it["context 2 should print"] = () =>
                    _output.ShouldBe("cl_before_all,cl_before_each,cl_act_each,");
            };
        }
    }

    public abstract class nspec_base : nspec
    {
        [Fact]
        public void run()
        {
            var currentSpec = GetType();
            var finder = new SpecFinder(new[] {currentSpec});
            var builder = new ContextBuilder(finder, new Tags().Parse(currentSpec.Name), new DefaultConventions());
            var runner = new ContextRunner(builder, new ConsoleFormatter(), false);
            var collection = builder.Contexts().Build();
            var results = runner.Run(collection);

            //assert that there aren't any failures
            var failures = results.Failures();
            var count = failures.Count();
            if (count > 0)
            {
                var target = LogManager.Configuration.FindTargetByName("memory") as MemoryTarget;
                target.Logs.Do(Console.WriteLine);
            }
            count.ShouldBe(0);

            // TODO: figure out how to programmatically skip, when there are pending
        }
    }
}

Installed SpecWatchr but no ruby files

Hi,
I have installed Specwatchr via nuget package manager console(install-package specwatchr), but there are no ruby files in my solution tree. I am particularly looking for dotnet.watchr.rb but it is not getting installed. Although it does install a file called specwatchr-usage.txt
VS 2012 PRO - VER 11.0
.NET FW 4.5
NSPEC VER 0.9.68
SPECWATCHR VER 1.7.5

Tests expecting exception pass when exception isn't thrown

My tests that expect<Exception>(() => do something...) always pass, even when the code in "do something..." doesn't throw an exception. Shouldn't they fail if an exception is not thrown?

This occurs no matter what type of exception I'm expecting. I would think the tests should fail when no exception is thrown and also fail when the wrong type of exception is thrown. Any ideas?

Data-driven tests & dynamically-generated tests

Xunit has awesome support for data-driven tests via the Theory attribute.

However, MbUnit goes one better and allows one to generate test cases in loops - RSpec also allows this (and IMO a bit more slickly, but that's probably ruby rather than the framework), and it's really powerful to just write standard code to generate test cases instead of learn test framework features to do so.

Can NSpec do this already, and if not, please could it join in?

exceptions in nspec class construction

if an exception occurs in the construction of an nspec specification, it breaks the rest of the specifications:

class describe_some_spec : nspec
{
public describe_some_spec()
{
//i know specification classes shouldn't have a constructor
//but if an exception is thrown here, then it breaks the rest of the contexts
}
}

parallel test execution

Some tests would be safe to run in parallel (maybe at the context level). MbUnit has a concept of parallelizable. Maybe parallel execution can be performed at some level in NSpec.

File path in failure stack trace.

Not sure if the file path is needed in the failure stack trace. Instead of:

nspec. describe specifications. when creating specifications. true should be false.
Expected: False, But was: True
   at describe_specifications.b__0() in c:\Projects\NSpec\SampleSpecs\WebSite\describe_specifications.cs:line 8

It may be more readable if it says:

nspec. describe specifications. when creating specifications. true should be false.
Expected: False, But was: True
   at describe_specifications.b__0() in SampleSpecs\WebSite\describe_specifications.cs:line 8

Team City

I have TeamCity as CI framework and I want run the tests over it, is it possible?

Thanks.

The spec method must contains '_'?

No DOC or the pages on nspec.org says the spec method must contains a '_', and so I just waste some time digging the src to find this...

If methods do not contain a '_' is treated as a helper method, not spec method, the DOC or some page on nspec.org should make this CLEAR

method level example output

method level examples should remove the it_ part of the specification from the output, same thing goes for specify_

it["sends an email"] has an output of "sends an email"

it_sends_an_email should have the same output, but has "it sends an email" instead.

Duplicated test output from spec with context in VB.NET

Am trying to use NSpec with VB.NET in VS2010 (nspec 0.9.67 installed via NuGet). Getting a strange output where a test inside a context is duplicated:

ExampleSpec
  Describe String Without Context
    compares with another string
  Describe String With Context
    This time with context
      compares with another string
   Lambda$  4
    compares with another string

3 Examples, 0 Failed, 0 Pending

Here's the simple example spec that generates this output:

Imports NSpec

Public Class ExampleSpec
    Inherits NSpec.nspec

    Private testString As String

    Sub Describe_String_Without_Context()
        before = Sub() testString = "This is a string"

        it("compares with another string") = Sub() testString.should_be("This is a string")
    End Sub

    Sub Describe_String_With_Context()
        before = Sub() testString = "This is a string"

        context("This time with context") =
            Sub()
                it("compares with another string") = Sub() testString.should_be("This is a string")
            End Sub
    End Sub
End Class

Am new to VB.Net and NSpec, have tried this in C# and it's fine, so could be something I am doing wrong in the way the VB.NET spec is written? Couldn't find any good examples of VB.NET and NSpec to refer to. Any thoughts?

Unable to use Specwatchr

Hi,
I tried to use specwatchr, but cannot get Growl for Windows to install properly. I get an error when trying to run the exe that I do not have the proper version for my system (Win7 x64). So I tried using it with Snarl and having all sorts of ruby issues with the ruby-snarl package. Any help you can offer to get this up an running? I do have it running in the command window, but the notifier would make it so much nicer.

Thanks.

wrong method execution order

Hi, I took my_first_spec from example and added after_xxx and before_xxx handlers; plus added a base class called common with its own hooks as described in http://stackoverflow.com/questions/10053168/reusing-nspec-specifications

The result code is: https://gist.github.com/VladimirLevchuk/8843432

and after execution I got the following output which means for me that describe_nesting is the first called method and before_xxx doesn't work as expected:

    my_first_spec: describe_nesting
    common: before_all
    common: before_each
    my_first_spec: before_each
    my_first_spec: it_works
    common: after_each

    my first spec
      it works
    common: before_each
    my_first_spec: before_each
    common: after_each
      describe nesting
        works here
    common: before_each
    my_first_spec: before_each
    common: after_each
        and here
    common: after_all

Failure to run NSpecRunner under Microsoft Moles

I'm unable to run NSpecRunner (v0.9.59.0) under Microsoft Moles.

When I issue the command:

moles.runner.exe /r:c:\dev\TestProject\tools\nspec\NSpecRunner.exe TestProjectSpec.dll

I get the following exception:

Microsoft Moles Runner v0.94.51023.0 -- http://research.microsoft.com/moles -- .
NET v4.0.30319
Copyright (c) Microsoft Corporation 2007-2010. All rights reserved.

instrumenting...started

Unhandled Exception: System.BadImageFormatException: Could not load file or assembly 'file:///c:\dev\TestProject\tools\nspec\NSpecRunner.exe'
 or one of its dependencies. An attempt was made to load a program with an incorrect format.
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark&stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm,Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at Microsoft.Moles.Runner.MolesRunner.RunnerRunner.Run(String runner, String[] args)
   at Microsoft.Moles.Runner.MolesRunner.RunnerRunner.Run(String runner, String[] args)
   at Microsoft.Moles.Runner.MolesRunner.LaunchRunnerEntryPoint(MolesRunnerOptions options)
   at Microsoft.Moles.Runner.MolesRunner.RunnerMain(String[] args)
   at Microsoft.Moles.Runner.Program.Main(String[] args)

stack trace not retained in method level before each

if a method level before_each throws an exception. the stack trace doesn't reflect why the exception occured.

class some_spec : nspec
{
    string nullString = null;
    void before_each()
    {
        var exceptionWillBeThrown = nullString.Substring(0, 10);
    }

    void specify_nullString_is_null()
    {
        nullString.should_be_null();
    }
}

before throwing messages when testing examples between contexts with selenium

Hello, I am trying to use Selenium with nspec and I am receiving the following message when running:

using NSpec;
using OpenQA.Selenium.Firefox;

namespace Specs
{
    class describe_google : nspec
    {
        private FirefoxDriver firefox;

        void before_all()
        {
            firefox = new FirefoxDriver();
        }

        void given_i_want_to_search_at_google()
        {
            before = () =>
                 firefox.Navigate().GoToUrl("http://www.google.com.br");

            it["should have Google Search button at the home page"] = () => {
                var elements = firefox.FindElementsByCssSelector("input");
                elements.should_contain(element =>
                    element.GetAttribute("value").Equals("Pesquisa Google"));
            };

            context["when submitting with \"kittens\" in the search box"] = () => {
                 it["should have \"q=kittens\" on the query string"] = () => {
                     var element = firefox.FindElementById("lst-ib");
                     element.SendKeys("kittens");
                     element.Submit();
                     firefox.Url.should_contain("q=kittens");
                 };
            };
        }
    }
}
PM> NSpecRunner.exe .\Specs\bin\Debug\Specs.dll

describe google
  before all
  given i want to search at google
    should have Google Search button at the home page - FAILED - collection does not contain an item it should., Expected: True, But was: False
    when submitting with "kittens" in the search box
      should have "q=kittens" on the query string - FAILED - Could not load file or assembly 'System.resources, Version=4.0.0.0, Culture=pt-BR, PublicKeyToken=b77a5c5619
34e089' or one of its dependencies. O sistema não pode encontrar o arquivo especificado.

**** FAILURES ****

nspec. describe google. given i want to search at google. when submitting with "kittens" in the search box. should have "q=kittens" on the query string.
Could not load file or assembly 'System.resources, Version=4.0.0.0, Culture=pt-BR, PublicKeyToken=b77a5c561934e089' or one of its dependencies. O sistema não pode encont
rar o arquivo especificado.
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark
, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)

   at System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(String name, CultureInfo culture, Version version, Boolean throwOnFileNotFound, StackCrawlMark& stac
kMark)

   at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo lookForCulture, StackCrawlMark& stackMark)

   at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExi
sts, StackCrawlMark& stackMark)

   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)

   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)

   at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)

   at System.SR.GetString(String name)

   at System.Net.NetRes.GetWebStatusString(String Res, WebExceptionStatus Status)

   at System.Net.HttpWebRequest.Abort(Exception exception, Int32 abortState)

   at System.Net.HttpWebRequest.SetResponse(CoreResponseData coreResponseData)

   at System.Net.HttpWebRequest.CheckWriteSideResponseProcessing()

   at System.Net.ConnectStream.ProcessWriteCallDone(ConnectionReturnResult returnResult)

   at System.Net.HttpWebRequest.WriteCallDone(ConnectStream stream, ConnectionReturnResult returnResult)

   at System.Net.ConnectStream.CallDone(ConnectionReturnResult returnResult)

   at System.Net.ConnectStream.ResubmitWrite(ConnectStream oldStream, Boolean suppressWrite)

   at System.Net.HttpWebRequest.EndWriteHeaders_Part2()

   at System.Net.HttpWebRequest.EndWriteHeaders(Boolean async)

   at System.Net.HttpWebRequest.WriteHeadersCallback(WebExceptionStatus errorStatus, ConnectStream stream, Boolean async)

   at System.Net.ConnectStream.WriteHeaders(Boolean async)

   at System.Net.HttpWebRequest.EndSubmitRequest()

   at System.Net.HttpWebRequest.CheckDeferredCallDone(ConnectStream stream)

   at System.Net.HttpWebRequest.GetResponse()

   at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)

   at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)

   at OpenQA.Selenium.Firefox.Internal.ExtensionConnection.Execute(Command commandToExecute)

   at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(DriverCommand driverCommandToExecute, Dictionary`2 parameters)

   at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value)

   at OpenQA.Selenium.Remote.RemoteWebDriver.FindElementById(String id)

   at Specs.describe_google.<given_i_want_to_search_at_google>b__4() in C:\Users\amadeus\Documents\Visual Studio 2010\Projects\NSpec\Specs\google_spec.cs:line 30

nspec. describe google. given i want to search at google. should have Google Search button at the home page.
collection does not contain an item it should., Expected: True, But was: False
   at Specs.describe_google.<given_i_want_to_search_at_google>b__1() in C:\Users\amadeus\Documents\Visual Studio 2010\Projects\NSpec\Specs\google_spec.cs:line 24

2 Examples, 2 Failed, 0 Pending

Using before_each instead of before works....

The NuGet packeg is Selenium.WebDriver

before_all exception handling

Hey guys, looks like there might be a small issue in the before_all class level method. I had an exception in my before_all method but I wasn't notified about it through the NSpecRunner. It wasn't until I was debugging the code that I was able to figure it out.

Any plans for having the before_all handle exceptions?

Sub context before_all running before parent before_each

Is there a way to have a before_all inside of a context only run after the parent context's before_each?

for example I'm doing the following gist

https://gist.github.com/4268265

<script src="https://gist.github.com/4268265.js"></script>

new_session_start inherits from nspec_driver

notice that driver is not created until the before each is run, so if before_all runs before that, the driver will not exist.

I also created another test class seeing if the behavior was different if it was all part of the same class, but it is not.

I tried doing a base.beforeEach.Invoke(), but I can't actually call that. Any ideas? Is this intended functionality?

Edit: I've edited my gist to only test if before_all runs before a parent before_each.

Generic baseclass support

Would be good if NSpec supported a generic baseclass, e.g

public class BaseClass : nspec
{
protected IDbSet DbSet
{
get { ... }
}

}

public class describe_RealTestClass : BaseClass
{
}

I find that my unit tests to verify the database bindings for the different models all are very similar and use the same resources over and over. Would be very good if NSpec supported this case.

NSpec 0.9.25 Can't Find Specs.

Following the guide on nspec.org when I run the NSpecRunner I get this as an output

PM> NSpecRunner.exe .\CodeSlice.UnitTesting.NSpec\bin\debug\NSpec.dll

0 Examples, 0 Failed, 0 Pending

However there is a spec already defined

class tag_spec : nspec
{
    void when_setting_the_tag_name()
    {
        before = () => _tag = new Tag { Name = "My Tag Name" };
        it["should normalise the tag name"] = () => _tag.NormalisedName.should_be("mytagname");
    }

    private Tag _tag;
}

I assume I am just doing something wrong but I can't see it.

method level act_each

if an exception is thrown in a method level act_each, the failures do not record correctly:

void act_each()
{
//throw some exception
}

Using other testing frameworks with NSpec.

Morning,

I had an interesting conversation with both my manager and application architect yesterday. Now my manager wanted to give me a great big hug for starting down the path on testing and saw huge advantage to “NSpec” as a testing framework. Again, he was happy to see anyone doing any sort of testing. However, the AA thought that we should be doing more traditional unit test i.e. testing each methods. Now I look at the source code and saw that in the code you are using NUnit framework in the background. So my question, is there a way that makes sense to combine the two processes together without overwhelming the developers?

Thanks again for your help on this,

James

AppDomain and CurrentDirectory is different from NUnit.

Let me preface by saying I am not an expert in C# or the .NET framework. I just stumbled on this.

When I run NUnit tests, either from ReSharper or with in VS2012, the AppDomain.CurrentDomain.BaseDirectory is the build output path from the project properties. ex

c:\vsprojects\mySolution\target\bin\debug\x64

Also the Directory.CurrentDirectory during launch is also the the build output path from the project properties, same example as above.

However when your run NSpecRunner from the package management console, obviously, the CurrentDirectory is current path where you executed NSpecRunner from and the AppDomain.CurrentDomain.BaseDirectory is
c:\Users\myuser\documents\Visual Studio 2012\Projects\mySolution\packages\nspec.0.9.67\tools.

Honestly I don't know if its relevant to even report it. Its just a minor inconsistency between the two, and I only stumbled upon it consuming someone else's library that relies on have a AppDomain.CurrentDomain.BaseDirectory\Bin directory.

Thank you for developing NSpec :)

XUnit Runner for NSpec

I tried the NSpec adapter for XUnit from another github user but it's very outdated and doesn't work in complex cases such as inheritance because of the way it builds the contexts.

I'm contemplating writing my own because installing ruby to run nspecs is bizarre to say the least given that VS2012 offers continuous integration.

Could you provide some guidance on how to do this? The little that I looked at your source, it seems to be geared towards building a context top-down (class-method) where as for XUnit it'd probably have to work bottom-up.

Thanks

NSpec DLL problems

Not sure if this is an issue with the nspecrunner or some poor configuration at my end but I was running into issues with running nspecrunner. It seemed that when I ran my tests the required 3rd party DLLs could not be found (they are in the same directory as the original dll) however running the code normally worked and copying nspecrunner.exe to the bim/Debug folder and running it there also worked.

Is there a way around this?

James

NSpec with Jenkins

I posted to this issue but since it's closed I doubt it will get a reply.

#50

Can NSpec 0.9.68 be used with Jenkins?

class level after_each are run once

If you define a class level after_each it will be run once before any other methods or tests in any test class.

It might also be good to describe the after function on the "documentation" page.

nspec.org samples

In the nspec.org sample code there are numerous examples of the following syntax

it["also works here"] = () => "hello".Should().Equal("hello");

Which I think is incorrect, it should be (pardon the pun)

it["also works here"] = () => "hello".should_be("hello");

Running Multiple Assembly With Nspec

We have a both Acceptance test and Unit test with the Nspec . I would like to run all the dll at once and get the report out of it . Currently it takes only one Assembly . I have forked the code to look at a way to do it

Statement without example (pending or otherwise)

If I am writing a spec, and just need to make a statement appear in my output, I believe my only option is to do something like:

it["As...."] = () => true.should_be_true();
it["I...."] = () => true.should_be_true();
it["So..."] = () => true.should_be_true();

Before I go further, I understand that nSpec isn't intended as a Gherkin-style BDD framework. That's just an example. The output should tell a story though, and many times you need to describe intent without running an example.

The output in this situation is fine, but it renders the example count useless. The example count is only a useful metric when it's not augmented by these statement affirmations. I'd like to get to work on adding a way to make a statement that isn't counted, but I'd like some guidance regarding the preferred implementation:

Should I add an action, similar to todo?

it["As..."] = stated;

or should I add an actionregister?

state["As..."] = stated;

or perhaps both, or something entirely different? If I implemented this functionality would you be interested in pulling it in?

How to give NSpec a more effective, more BDD syntax.

I'm deciding between NSpec and xBehave.net, looking at these code samples: xBehave.net, NSpec. NSpec looks great because test names can be strings with spaces, and I'll be typing a lot of them. But there are a few things that I think will confuse newcomers and/or cause people to focus on test implementation rather than behavior:

  • It uses "before, act, it" verbage, which focuses on test implementation rather than behavior. "Given, when, then" is what's stated in the original BDD post. This encourages behavior-focused tests.
  • It doesn't have a spot to type in all three of these clauses (even if some were optional), just the last "It" clause. So tests can't be read at a glance.
  • The word "Context" doesn't have a lot of specific meaning. The contexts in the example are just tests. But use the word "behavior", instead, per the the original BDD post's section '“Behaviour” is a more useful word than “test”'. This encourages behavior-focused tests.

I think NSpec would be much more appealing, and "more BDD" with this syntax:

behavior["when the site already exists"] = () =>
{
    given["the account has a site"] = () => account = GetAccountWithSite();

    when["I add a site"] = () => account.AddSite("sites/1");

    then["it throws excepton"] = expect<InvalidOperationException>();
};

That's consistent, readable, and keeps the programmer focused on behavior. If you think the clauses are too wordy, their strings could be made optional (at least Given and When, since those aren't even possible now).

Is this possible to implement, and any chance of getting it as an option in a future version? Thanks!

MySQL Server Issue

I try to use NSpec with MySQL but i have issues with it. Is there a solution for this? Thanks.

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.