machine / machine.specifications

Machine.Specifications is a Context/Specification framework for .NET that removes language noise and simplifies tests.
MIT License
885 stars 178 forks source link

dotnet test cannot find any contexts and specifications #315

Closed gpasnik closed 8 years ago

gpasnik commented 8 years ago

Hi, I have a problem with running unit tests. I made a class library for mspec tests with one dummy test inside.

[Subject("Test")]
public class When_dummy_test
{
    protected bool Value;

    Because of => () => Value = true;

    It should_be_true => () => Value.ShouldBeTrue();
}

and project.json is exactly the same as here https://github.com/machine/machine.specifications/wiki/.NET-Core-(.NET-CLI)

But when I want to run tests with "dotnet test" I see this:

dotnet test
Project Coolector.Tests (.NETCoreApp,Version=v1.0) was previously compiled. Skipping compilation.
dotnet-test-mspec: 0.2.0
Machine.Specifications: 0.11.0
Contexts: 0, Specifications: 0, Time: 0.07 seconds
SUMMARY: Total: 1 targets, Passed: 1, Failed: 0.

dotnet info:

dotnet --info
.NET Command Line Tools (1.0.0-preview2-003131)

Product Information:
Version:            1.0.0-preview2-003131
Commit SHA-1 hash:  635cf40e58

Runtime Environment:
OS Name:     Windows
OS Version:  10.0.14393
OS Platform: Windows
RID:         win10-x64

Does anyone else have the same problem?

ivanz commented 8 years ago

Thanks for the report - I see this as well. I wonder if it's related to the recent updates to .Net Core and the preview tooling. Will have a look.

ivanz commented 8 years ago

Weirdly enough MSpec's own tests work fine:

c:\code\machine.specifications\Source\Machine.Specifications.Specs>dotnet test

dotnet-test-mspec: 0.2.0
Machine.Specifications: 1.0.*
Specs in Machine.Specifications.Specs:

// snip...

Contexts: 78, Specifications: 186, Time: 2.27 seconds
ivanz commented 8 years ago

@gpasnik You have typos, which with the newer C# compilers is valid syntax (expression bodied member).

Because of **=>** () => should be Because of **=** () =>, so = instead of =>

MSpec ignores classes without Because

gpasnik commented 8 years ago

I see. Very thanks for help! I couldn't find this on my own, thanks once again! 👍