nspec / NSpec

A battle hardened testing framework for C# that's heavily inspired by Mocha and RSpec.
http://nspec.org/
MIT License
260 stars 57 forks source link

it / specify on class level do not work #205

Closed dhilgarth closed 6 years ago

dhilgarth commented 6 years ago

According to the documentation, the following code should work:

class describe_NSpec : nspec
{
    void it_just_works()
    {
        "hello".should_be("hello");
    }
}

But it doesn't. It doesn't pick up the assertions.

amirrajan commented 6 years ago

Does specify work?

dhilgarth commented 6 years ago

No

amirrajan commented 6 years ago

😲 @BrainCrumbz

BrainCrumbz commented 6 years ago

@dhilgarth could you please double check either the version, or where are you getting should_be from?

Those assertion helpers where available in older NSpec versions, and documentation has not been updated yet. In most recent versions the number of assertions shipped with NSpec has been drastically reduced to only those available under NSpec/Assertions/AssertionExtensions, in favour of importing your own preferred assertion library.

Just to mention, examples found in NSpec/examples/ directory use Shouldly.

I understand this behaviour is strange, but that would be the first thing I'd check.

Second check: how are you running the test? From NSpecRunner command line tool? Or Visual Studio? Which version with which tool, in case? HTH

dhilgarth commented 6 years ago

Ehm, that's right, I was using v1.0.7. I installed NSpec.VsAdapter and didn't realize that it didn't depend on the latest nspec. I later removed NSpec.VsAdapter but never verified that I was using the latest NSpec version. Thanks for the hint!

BrainCrumbz commented 6 years ago

Glad you made it work!
Actually you can use NSpec.VsAdapter (in VS2013/15 as an extension, and in VS2017 as a package) even with the latest NSpec version.

amirrajan commented 6 years ago

@dhilgarth thanks for the heart attack :-P

dhilgarth commented 6 years ago

So sorry :grimacing: