Questions tagged [mspec]

Machine.Specifications is a context/specification framework for C#. Not to be confused with the mspec Ruby framework (tag [mspec-ruby]) used in RubySpecs.

Machine.Specifications is a context/specification framework for C# geared towards removing language noise and simplifying tests.

215 questions
4
votes
2 answers

How to avoid DisconnectedContext exception when debugging MSpec tests?

I get a DisconnectedContext error when debugging MSpec tests, even in a new project with an empty test. The message says that the Managed Debug Assistant found a problem in C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO…
Pad
  • 47
  • 1
  • 6
4
votes
3 answers

Why does Visual Studio 2015 console runner not recognize MSpecs?

I've written some MSpecs, but Visual Studio (2015) test runner does not recognize them. I've added the Machine.Specifications.Runner.Console and all required Machine.Specification-packages using the NuGet-PM. But when I choose Test->Run Test, the…
krouch
  • 105
  • 9
4
votes
2 answers

MSpec Json.NET deserialization test fails in ReSharper but passes in NCrunch

I have the following two unit tests: one using MSTest and one using Machine Specifications. As far as I can see they should behave identically. However, while the first one passes in both the NCrunch and ReSharper test runners, the second one fails…
Blisco
  • 601
  • 6
  • 14
4
votes
0 answers

How do I use "included" files in an MSpec test run?

I have a test project and I'm using MSpec for some of the tests (mixed project with both MSpec and VSTest). I have a method that operates on a text file and requires a path to the file. My problem is that the current directory for the file doesn't…
Mark J Miller
  • 4,751
  • 5
  • 44
  • 74
4
votes
2 answers

How do I run MSpec test assemblies in parallel?

We have the following setup: Team City v8.1.2 .NET 2013 Solution with several different C# projects (ASP.NET MVC, libraries, testing projects, etc.) 95% of our tests are MSpec, but we also have some NUnit tests. We have 14 test projects and…
Javier Holguera
  • 1,301
  • 2
  • 11
  • 27
4
votes
1 answer

How do I get past the "No tests found in file" error in MSpec when everything is written correctly?

I have tried these two tutorials and a project of my own with MSpec but I am getting the error "No tests found in file" every time. I have also looked at this SO solution. And I made sure my classes are public. I would post code but I literally have…
Sealer_05
  • 5,346
  • 8
  • 35
  • 53
4
votes
1 answer

Why does a parsed double not equal an initialized double supposedly of the same value?

When I execute this line: double dParsed = double.Parse("0.00000002036"); dParsed actually gets the value: 0.000000020360000000000002 Compared to this line, double dInitialized = 0.00000002036; in which case the value of dInitialized is exactly…
Tim Long
  • 13,508
  • 19
  • 79
  • 147
4
votes
2 answers

How do I enforce test isolation in MSpec when static members/methods are required?

Ok. I'm trying to wrap my head around why MSpec uses static methods / variables. (Well not exactly static methods, but with member variable delegates, it's practically the same). This makes it impossible to reuse contexts. That or go through and…
Sleeper Smith
  • 3,212
  • 4
  • 28
  • 39
4
votes
0 answers

How would I test an attribute-based validation model with MSpec?

I have a model with certain attributes that restrict the values that that model can take. How do I test the model state of this model using MSpec?
Sachin Kainth
  • 45,256
  • 81
  • 201
  • 304
4
votes
1 answer

How do I run MSpec in Visual Studio's test system using Gallio?

I'm trying to run MSpec tests in Visual Studio's test system using Gallio, but it appears to be ignoring the MSpec plugin from the IDE. What I did: Installed Gallio Added the MSpec NuGet package to my test project Added the Gallio NuGet package to…
Richard Szalay
  • 83,269
  • 19
  • 178
  • 237
3
votes
1 answer

Is this a clean BDD/MSpec test?

I have a static class Cryptographic that can Encypt and Decrypt a string. I have written the following specs for this: [Subject(typeof(Cryptographic))] class When_encrypting_and_decrypting_a_string { Establish context = () => { input =…
bitbonk
  • 48,890
  • 37
  • 186
  • 278
3
votes
2 answers

How do you name xSpecification/BDD test classes so that they convey the intent? Especially in the Solution Explorer

I've recently adopted strongly following BDD design along with usage of MSpec for implementing xSpecification tests. This has been leading to some rather insane class names that become hard to distinguish intent inside the solution explorer. Take…
Chris Marisic
  • 32,487
  • 24
  • 164
  • 258
3
votes
2 answers

Can you integrate MSpec with the MonoDevelop test runner?

Can you integrate MSpec with the MonoDevelop test runner? It's working in Sharp-Develop. Google says 'nothing' so I'm guessing it's not possible as of the current release (2.8.2).
Edward Wilde
  • 25,967
  • 8
  • 55
  • 64
3
votes
3 answers

How do I assert that a method is called only once?

[Subject(typeof(OnceADayProcessor))] public class When_processing_process_twice { private static ICanBeProcessedOnceADay ProcessedOnceADay; private Establish context = () => { OnceADayProcessor.Now = () => new DateTime(2011, 1, 1, 0, 0, 0,…
Rookian
  • 19,841
  • 28
  • 110
  • 180
3
votes
1 answer

Can this MSpec test be improved?

As a BDD and MSpec beginner I am still not so sure about best practises and good habits related to BDD in general and specifically to MSpec. Can the following example be improved? Does it follow best practises and good habits? Is the naming of my…
bitbonk
  • 48,890
  • 37
  • 186
  • 278