Machine.Specifications has moved. It now has it's own repository at github.com/machine/machine.specifications
Machine is a collection of libraries and utilities.
Machine.Specifications is a Context/Specification framework for .NET that removes language noise and simplifies tests.
License: MIT License
Any ideas when a R# 6 runner will be available?
A simple implementation of an assertion library would make things faster and require less moving parts.
The current implementation of ShouldNotBeNull is for object, enabling value types. No compilation or running error when type is value type (Problem when you think you work on a reference type, but really aren't.)
Rewrite to the following to give compilation error when value type:
public static string ShouldNotBeNull(this T anObject) where T:class
{
if (anObject == null)
{
throw new SpecificationException(string.Format("Should be [not null] but is [null]"));
}
}
InstallResharperRunner.5.0.bat doesn't install the runner for VS2010. This is a simple addition to the batch file to copy things to "%APPDATA%\JetBrains\ReSharper\v5.0\vs10.0\Plugins" as well as "%APPDATA%\JetBrains\ReSharper\v5.0\vs9.0\Plugins", and I think some people have this fix in their own forks, but it hasn't been pulled to the official fork yet.
I would like to use another assertion library within mspec. Such as sharptestex.codeplex.com for example.
The problem is that mspec assertions are clattering my intelisence with various ShouldXXX, while I dont need them, because I use only one SharpTestsEx extension methon "Should()".
MSpec is awesome anyway. Thank you for you work!
Would be cool if the following could be made possible:
[Ignore("Currently failing because of some issues")]
Behaves_like a_vending_machine
Thanks
It's simple test below but I can't make it pass because I got "should return correct result : Failed Expected: RSpecModel.Story
But was: RSpecModel.Story". Is there any trick to make this test pass?
[Subject("ObjectHelpers")]
public class when_copy_EF_entity
{
private static Story story;
private static Story newStory;
private Establish context
= () =>
{
story = new Story() { Role = "some role",
Benefit = "some benefit",
Feature = "some feature",
StoryId = 12,
ProjectId = 1,
ChangedBy = 1,
ChangedTime = Convert.ToDateTime("5/1/2010")
};
newStory = new Story();
};
private Because of
= () =>
{
ObjectHelpers.CopyObject(story, ref newStory);
};
private It should_return_correct_result
= () =>
{
newStory.ShouldEqual(story);
};
}
I have a strange effect.
When I have MSpec resharper runner V 0.4.22.0 "installed" in the Resharper Plugins folder, the xUnit resharper runner is not capable of showing the correct class and method names of test classes and test methods. It shows only a generic "UnitTestMethodElement" entry instead of the real method name.
This happens only when both resharper runners are loaded as plugins. If only xUnit is loaded, it works correctly.
Also, xUnit runner can execute the tests, the only problem is the displaying of the naes of classes and methods.
Although xUnit does not behave correctly, I post this issue here under MSpec, because the effect is clearly caused by MSpec somehow.
Hi Aaron and friends - really digging MSpec so far, but I wanted to use it with xunit because Brad will smack my upside the head if I don't!
I found an issue, however, when using the Extensions. You can repro this using the latest trunk:
You should get an error that says:
System.IO.FileNotFoundException: Could not load file or assembly 'xunit, Version=1.1.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c' or one of its dependencies. The system cannot find the file specified.
File name: 'xunit, Version=1.1.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c'
at Machine.Specifications.XUnitShouldExtensionMethods.ShouldEqual[T](T actual, T expected)
D:\MSpec\machine.specifications\Source\Machine.Specifications.Example\BankingSpecs.cs(16,0): at Machine.Specifications.Example.when_transferring_between_two_accounts.<.ctor>b__6()
D:\MSpec\machine.specifications\Source\Machine.Specifications\Model\Specification.cs(75,0): at Machine.Specifications.Model.Specification.InvokeSpecificationField()
D:\MSpec\machine.specifications\Source\Machine.Specifications\Model\Specification.cs(53,0): at Machine.Specifications.Model.Specification.Verify()
I don't have nunit in my GAC
I'm running Win7 RC1 with VS 2008 SP1
It looks like it's a simple proximity issue with the xunit dll - and I looked in the libraries and it's there (xunit.dll) so I'm not entirely sure why it's not loading.
If you switch back to the NUnit extensions - everything works.
Hi there, I've been using machine.specifications for a while and really like it.
I've started to run browser tests with it and that's going well but I've been using WatiN 2.1, which has a new methods that I use (e.g. List), which means I can't easily go back to using 2.0.
I want to start using WatinResultSupplementer but this seems to only work if you're using WatiN 2.0, so I was wondering if there were plans to update your WatiN support to version 2.1?
Thanks,
Adam.
Accidentally closed last one.
When installing the resharper runner from .NET 4.0 branch I received a CAS security exception from VS2010. Operation Not Supported. Exception from HRESULT 0x80131515
Despite the Subject attribute being in place, it's sometimes not reported in the gutter popup nor the Unit Test Session window. Seems like invalidation does not happend when changing, adding or removing the Subject.
If you have a generic behaviour type it doesn't get executed by the R# runner but it does by the MSpec one. For example
[Behaviors]
public class ItHasManyChildren : Scenario
{
It should_have_many_children =()=> { }
}
Will not get run and appear as ignored in the R# runner
When doing the following in establish:
DispatcherSynchronizationContext syncContext = new DispatcherSynchronizationContext();
SynchronizationContext.SetCurrent(syncContext);
An BadImageFormatException is thrown when I try to run the tests in the resharper runner. Any ideas?
Ignored specifications in html report are shown as regular passed specifications. I expect them to see with an indication that they are ignored, similar to "not implemented" ones.
It's looks like x.GetType() == y.GetType() is called too soon in the shouldequal method:
base.Equals(derived).ShouldBeTrue(); // passes
base.ShouldEqual(derived); // fails
Visual Studio 2010 with Resharper 5 stops responding and has to restart when writing specs. I don't know if mspec is the one causing the problem, but the only crashes I get from VS2010 is when I am writing specifications.
In my TeamCity logs, I see the following:
[10:06:27]: [Step 2/4] ##teamcity[message test='Exception has been thrown by the target of an invocation.'
errorDetails='<exception details and stack trace goes here>' status='ERROR'']
[10:06:28]: [Step 2/4] Property value not found
Valid property list format is (name( )*=( )*'escaped_value'( )*)* where escape simbol is "|"
I think that this is because of the spurious extra single quote at the end ('']
)
It looks like it's added (unconditionally) by TeamCityErrorMessageWriter.WriteError, at line 245 or so.
I just heard Joel Semeniuk talk about MSpec on the .NET Rocks podcast. I came here to look into it more, but I'm surprised to see so little documentation or even basic info on what it is and how to use it. I'm not really complaining since it is free, but as an outsider looking in, that seems to be the most obvious need. Hope this helps. :)
Unclear from the -? description that --xml path requires path to a file. Similarly to the --html option, which manages with a directory, it says: "Outputs an XML file(s) to path"
Hi,
consider the following test:
var result = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.";
var original = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aaliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.";
original.ShouldEqual(result);
MSpec reports the errors as one line:
Machine.Specifications.SpecificationException: Should equal "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." but is "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aaliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
NUnit gives this ouput for the same sample:
Expected string length 591 but was 592. Strings differ at index 123. Expected: "...nt ut labore et dolore magna aliquyam erat, sed diam volup..." But was: "...nt ut labore et dolore magna aaliquyam erat, sed diam volu..." --------------------------------------------^
I think NUnits report is much clearer and really helps if something goes wrong.
Since we have a new OpenSouce dojo in Hamburg (https://www.xing.com/events/opensource-dojo-676691) we would like to implement this feature during our next dojo.
What do you think?
Best regards,
Steffen
There is a problem in behaviors that allows execution-order-dependent false results to sneak in.
When a behavior is run, for all protected static fields that are shared between the the context and behavior, the values are copied from the context to the behavior. The current implementation is that if a protected static field exists in the behavior but does not exist in the context, that field will not be touched. In this case, the actual contents of the field would depend on what other contexts had already been run. If another context that did have a matching field had been previously run, then the value copied for that context would still be in the behavior's field during the execution of the current context (the one not having a matching field). But if the current context was the first to run, then the field would have its default value. This usually causes different spec results depending on execution order.
I believe the fix is to require that all static protected fields in the behaviors have matching static protected fields in the contexts so a new value can be copied for every context. If this isn't true then a SpecificationException describing the problem is thrown. Conceptually, there should be no reason to have a static protected field in a behavior unless the specs in that behavior intend to use it to receive values from a context, and if that's the case, then the context had better implement a matching source field. The potential problem here is that if people have already written behaviors that have static protected fields that their contexts don't have, and (for some strange reason) they want it that way, then this would be a breaking change.
An alternative fix would have been to initialize all fields in the behavior to their default values before running each context so that if a context fails to implement one of the fields the specs in the behavior will probably fail. However, this has some performance implications and also makes the likely unexpected results more difficult to troubleshoot since would not be immediately apparent why the field in the behavior has a default value rather than a value from the context.
I've already implemented the proposed fix in my private repo. Any feedback on the desirability of that fix vs. the alternate fix before I submit it?
The following spec does not fail although it should:
it should_fail_because__hello_world__contains__hello__but_does_not =
() => "hello world".ShouldNotContain("hello");
whereas this one fails correctly:
it should_fail_because_1_2_3_contains_2 =
() => (new[] { 1, 2, 3 }).ShouldNotContain(2);
For now I'm using this workaround:
it should_fail_because__hello_world__contains__hello__and_does_fail =
() => "hello world".Contains("world").ShouldBeFalse();
It would be nice if there would be a ShouldContain() and ShouldNotContain() overload for strings to be able to do away with the mentioned solution. It can also be very misleading that this Extension method can be called on strings, but gives unexpected results.
I am willing to help, so if you can tell me how to submit a solution (e.g. updated ExtensionMethods.cs) I will try to fix this issue.
it should_be_possible_to_figure_this_out =
() => true.ShouldBeTrue();
Love your framework,
Thorsten
Currently, inherited It-Statements are ignored by the runner (or, to be specific, by the ContextFactory, as far as I was able to understand). It might be helpful to run base statements, too. Example attached.
public abstract class TestBase
{
protected static Item _sut;
Because of =()=> _sut.UpdateValues();
It should_always_be_true =()=> _sut.Quality.ShouldEqual(3);
}
[Subject("The It part of TestBase should always be executed")]
public class SomeTest : TestBase
{
Establish context =()=> _sut = new Item(5);
It should_test_something_with_this_instance =()=> _sut.SellIn.ShouldEqual(9);
}
The ShouldBeEmpty(string) extension method is implemented using String.IsNullOr Empty.
This means that the assertion is valid when either the string is null or it is empty.
This is not what the method name implies. In my opinion an empty string is a string instance with a length of 0, it should not be null.
I think that either the method name should be changed to IsNullOrEmpty or the method should be implemented to do as the method name suggests; check for a string that is empty (not null).
I have just gone through this thoroughly for a couple of days on and off. After having the R# guys almost remote desktop:ing in to my computer to look for why intellisense and refactor_rename was not working I thought of disabling the mspec runner plugin. This made R# start working again so for some reason your runner corrupts R#.
I am on VS2010, Windows 7 x64 and no other plugins, extensions or add-ins installed.
I'm trying to reference MSpec via OpenWrap (by way of the automatic conversion of NuGet packages), and I'm running into a bizarre issue. It seems like the Machine.Specifications.dll from the NuGet package is compiled differently and doesn't include the necessary public key. The error I'm getting is:
Error: Runner failure: System.Runtime.Serialization.SerializationException: Type is not resolved for member 'Machine.Specifications.Runner.RunOptions,Machine.Specifications, Version=0.3.0.0, Culture=neutral, PublicKeyToken=5c474de7a495cff1'.
at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)
at Machine.Specifications.Runner.Impl.AppDomainRunner.CreateRunnerAndUnloadAppDomain(String runMethod, AppDomain appDomain, Assembly assembly, Object[] args) in d:\BuildAgent-02\work\38fe83de684fd902\Source\Machine.Specifications\Runner\Impl\AppDomainRunner.cs:line 90
Test 'T:Medsphere.Cab.Tests.Events.EventAggregatorTests.EventAggregatorSpecs' failed: Type is not resolved for member 'Machine.Specifications.Runner.RunOptions,Machine.Specifications, Version=0.3.0.0, Culture=neutral, PublicKeyToken=5c474de7a495cff1'.
System.Runtime.Serialization.SerializationException: Type is not resolved for member 'Machine.Specifications.Runner.RunOptions,Machine.Specifications, Version=0.3.0.0, Culture=neutral, PublicKeyToken=5c474de7a495cff1'.
at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)
at Machine.Specifications.Runner.Impl.AppDomainRunner.CreateRunnerAndUnloadAppDomain(String runMethod, AppDomain appDomain, Assembly assembly, Object[] args)
at Machine.Specifications.Runner.Impl.AppDomainRunner.RunMember(Assembly assembly, MemberInfo member)
at Machine.Specifications.TDNetRunner.SpecificationRunner.RunMember(ITestListener testListener, Assembly assembly, MemberInfo member)
at TestDriven.TestRunner.AdaptorTestRunner.Run(ITestListener testListener, ITraceListener traceListener, String assemblyPath, String testPath)
at TestDriven.TestRunner.ThreadTestRunner.Runner.Run()
This happens if I use the console runner (mspec.exe) or via TestDriven.NET.
In digging, I loaded up my compiled assembly in ildasm, and I see that the reference to Machine.Specification.dll for my project includes the version number, but not the public key for the referenced Machine.Specifications.dll. When I compare ildasm of the Machine.Specifications.dll from OpenWrap/NuGet and the version from the zipfile on CodeBetter, the MANIFEST shows a public key in the CodeBetter version, but no public key in the OpenWrap/NuGet one.
If this in fact turns out to be the right analysis, can we please get an updated NuGet package that has a proper public key set in Machine.Specifications.dll?
I've got some code in a static constructor (.cctor) that expects Directory.GetCurrentDirectory() to be set to the assembly location. In the ReSharper runner, this works correctly. In the default runner (as used in TeamCity), it doesn't.
It looks as if, when the AssemblyExplorer class is looking for contexts, it loads the assembly:
at My.TestEnvironment.SetUpThings() in (ellided)
at My.Tests.TestBase..cctor() in (ellided)
--- End of inner exception stack trace ---
at My.Tests.TestBase..ctor()
at My.Tests.TestThings.the_test..ctor() in (ellided)
--- End of inner exception stack trace ---
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, ...)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, ...)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, ...)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at Machine.Specifications.Explorers.AssemblyExplorer.<FindContextsIn>b__0(Type x)
in path\to\mspec\Source\Machine.Specifications\Explorers\AssemblyExplorer.cs:line 23
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at Machine.Specifications.Runner.Impl.AssemblyRunner.Run(Assembly assembly, IEnumerable`1 contexts)
in path\to\mspec\Source\Machine.Specifications\Runner\Impl\AssemblyRunner.cs:line 46
...which causes the static constructor to be called, which fails.
Otherwise, the tests aren't actually called until the AppDomainRunner sets up the AppDomain with the correct ApplicationBase.
Obviously, I can work around this by moving my initialization out of the static constructors into an Establish
step, but it might work better if either MSpec used reflection-only assembly loading (which is ugly, I know), or if it ran AssemblyExplorer in an appdomain configured the same as it will use for the actual contexts.
Hello, I'm having troubles with the ShouldContain Method on an object array.
I have a Test like this:
static Dictionary<string, Tuple<object,bool>> criterias;
Establish context = () =>
{
new SchemaExport(_configuration).Execute(false, true, false);
CreateInitialData();
repository = new CRUDRepository<Guid, Product>();
criterias = new Dictionary<string,Tuple<object,bool>>();
criterias.Add("Category",new Tuple<object,bool>("Fruits",false));
};
protected static Product[] _products = new[]
{
new Product {Name = "Melon", Category = "Fruits"},
new Product {Name = "Pear", Category = "Fruits"},
new Product {Name = "Milk", Category = "Beverages"},
new Product {Name = "Coca Cola", Category = "Beverages"},
new Product {Name = "Pepsi Cola", Category = "Beverages"},
};
protected static void CreateInitialData()
{
using (ISession session = _sessionFactory.OpenSession())
using (ITransaction transaction = session.BeginTransaction())
{
new SchemaExport(_configuration).Create(true, true);
foreach (var product in _products)
session.Save(product);
transaction.Commit();
}
}
Because of = () =>
fromDbList = repository.Get(criterias);
It should_have_returned_data = () =>
fromDbList.Count.ShouldEqual(2);
It should_have_all_entitys_with_criterias = () =>
fromDbList.ShouldContain(new[] { _products[0], _products[1] });
I'm using NHibernate and everything is working fine, the products get created and updated in the array, so fromDbList ends up containing Product instances from the "fruits" category...
So the issue is:
fromDbList contains 2 objects, that compared separately are equal to the corresponding _products object (Product implements IEquatable) (fromDbList[0].Equals(_products[0]) returns True) but the method fails, I suppose it's because the instances in fromDbList are not the same instances in _products, but the fact is that the objects are equal in form.
Am I Doing something wrong? I would like not have to test for each object separately (witch is what I'm doing now), I understand that if you have a list with objects A and B, that equals C and D, the list doesn't contain C and D, is there a way to test if each object of a list equals corresponding objects on another list?
Maybe I'm missing something...
Awesome tool by the way! Doing testing for MVC3 with meta-programing and MSpec is working grate!
I hope the issue is understandable, any explanation needed please ask. Thanks!
I'm getting this exception when running the latest build from CodeBetter TeamCity server:
Runner failure: System.Runtime.Serialization.SerializationException: Type is not resolved for member 'Machine.Specifications.Runner.RunOptions,Machine.Specifications, Version=0.4.109.0, Culture=neutral, PublicKeyToken=null'.
at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)
at Machine.Specifications.Runner.Impl.AppDomainRunner.CreateRunnerAndUnloadAppDomain(String runMethod, AppDomain appDomain, Assembly assembly, Object[] args) in d:\BuildAgent-01\work\3a9aaebb4708e87c\Source\Machine.Specifications\Runner\Impl\AppDomainRunner.cs:line 90
Type is not resolved for member 'Machine.Specifications.Runner.RunOptions,Machine.Specifications, Version=0.4.109.0, Culture=neutral, PublicKeyToken=null'.
When running a set of specifications then sometimes the icons (on the individual specs) are wrong (successful/ignored/failed). The summary shown in the Unit Test Session Window is correct, but some icons are wrong.
The wrong icons are first set correctly (when the spec is run) and then they are set again (image flickering) to the wrong value. It seams that when the icon for a failed or ignored test is set, other icons are updated as well.
Cheers
Urs
I would like to be able to use Behaves_like
in context classes so that behaviors that are shared by multiple specs can be put in a base class. Right now I need to add them to every spec which seems redundant and is easy to forget.
Hi,
currently timing info is present for the complete run and each assembly. But we also like to see timing details for concern, context and each specification.
Thanks,
Daniel
Hi,
I am in the train, so I can send you more. But the following code creates a weird error on the cmd runner:
public class when_having_one_because
{
protected static int x;
Because of = () => x = x + 1;
}
public class when_having_another_because : when_having_one_because
{
Because of = () => x = x + 1;
It should_not_allow_this = () => x.ShouldEqual(2);
}
Cheers,
Steffen
Any idea what it would take to get MSpec working with .Net 4?
Under ReSharper 5.1, the test runner crashes with the following error
Unit test runner failed to load assembly: JetBrains.ReSharper.TaskRunnerFramework.TaskException : Failed to write to an IPC port: the pipe is being closed
When installing the resharper runner from .NET 4.0 branch I received a CAS security exception from VS2010.
Currently when an assertion is violated you see MSpec frames in the stack trace. We should remove these like NUnit/XUnit does.
Testing for expected exceptions should be more straight forward. A ShouldThrow() extension method will be much appreciated!
Please don't generate report files when there are no specs inside an assembly. In addition don't generate the resource folder.
everything works great until I add my MSpec project to source control. Then running the tool with --html for the report - always ends with "Access to the path 'all-wcprops' is denied."
Issue has a Jira Ticket with Jetbrains here:
http://www.jetbrains.net/jira/browse/RSPL-2540
It seems that Dictionary2 has been removed from the Util.dll in resharper 5.0. In the ContextCache class if you change it to use a Dictionary instead of Dictionary2 it works as a temporary fix. I'm not sure if Jetbrains is planning on removing this from the final 5.0 build or not.
Whenever I use anything other than Assert.IsTrue/IsNull I get the following issue. This occurs if I run from R# or TD.NET test runners.
Should Test Something : FailedAn exception occurred while verifying an assertion.
System.InvalidOperationException: The runtime has not been initialized.
at Gallio.Runtime.RuntimeAccessor.get_Instance() in c:\Server\Projects\MbUnit v3.2\Work\src\Gallio\Gallio\Runtime\RuntimeAccessor.cs:line 41
at Gallio.Framework.ComparisonSemantics.get_Default() in c:\Server\Projects\MbUnit v3.2\Work\src\Gallio\Gallio\Framework\ComparisonSemantics.cs:line 59
at MSpecSandBox4.When_Testing_Environment.<.ctor>b__0() in E:\Projects\2010\Presentations\BDD\MSpecSandBox4\TestConcern.cs:line 15
at Machine.Specifications.Model.Specification.InvokeSpecificationField() in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications\Model\Specification.cs:line 75
at Machine.Specifications.Model.Specification.Verify() in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications\Model\Specification.cs:line 53
at Machine.Specifications.Runner.Impl.SpecificationRunner.Run(Specification specification) in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications\Runner\Impl\SpecificationRunner.cs:line 25
at Machine.Specifications.Runner.Impl.SetupOnceContextRunner.RunSpecifications(Context context, ISpecificationRunListener listener, RunOptions options, IEnumerable1 resultSupplementers) in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications\Runner\Impl\ContextRunner.cs:line 55 at Machine.Specifications.Runner.Impl.SetupOnceContextRunner.Run(Context context, ISpecificationRunListener listener, RunOptions options, IEnumerable
1 globalCleanups, IEnumerable1 resultSupplementers) in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications\Runner\Impl\ContextRunner.cs:line 28 at Machine.Specifications.Runner.Impl.AssemblyRunner.RunContext(Context context, IEnumerable
1 globalCleanups, List1 supplements) in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications\Runner\Impl\AssemblyRunner.cs:line 78 at Machine.Specifications.Runner.Impl.AssemblyRunner.Run(Assembly assembly, IEnumerable
1 contexts) in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications\Runner\Impl\AssemblyRunner.cs:line 48
at Machine.Specifications.Runner.Impl.DefaultRunner.StartAssemblyRun(Assembly assembly, IEnumerable1 contexts) in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications\Runner\Impl\DefaultRunner.cs:line 112 at Machine.Specifications.Runner.Impl.DefaultRunner.StartRun(IDictionary
2 contextMap) in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications\Runner\Impl\DefaultRunner.cs:line 102
at Machine.Specifications.Runner.Impl.DefaultRunner.RunClass(MemberInfo member, Assembly assembly) in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications\Runner\Impl\DefaultRunner.cs:line 80
at Machine.Specifications.Runner.Impl.DefaultRunner.RunMember(Assembly assembly, MemberInfo member) in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications\Runner\Impl\DefaultRunner.cs:line 54
at Machine.Specifications.ReSharperRunner.Runners.RecursiveMSpecTaskRunner.Finish(TaskExecutionNode node) in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications.ReSharperRunner.4.1\Runners\RecursiveMSpecTaskRunner.cs:line 64
at JetBrains.ReSharper.TaskRunnerFramework.CurrentAppDomainHost.Execute(TaskExecutionNode node)
at JetBrains.ReSharper.TaskRunnerFramework.CurrentAppDomainHost.DoExecuteNodes(IEnumerable1 nodes) at JetBrains.ReSharper.TaskRunnerFramework.CurrentAppDomainHost.ExecuteNodes(IList
1 nodes)
at JetBrains.ReSharper.TaskRunnerFramework.TaskRunnerHostBase.ExecuteSerializedTree(String serializedTree)
Gallio.Framework.Assertions.AssertionFailureException: An exception occurred while verifying an assertion.
System.InvalidOperationException: The runtime has not been initialized.
at Gallio.Runtime.RuntimeAccessor.get_Instance() in c:\Server\Projects\MbUnit v3.2\Work\src\Gallio\Gallio\Runtime\RuntimeAccessor.cs:line 41
at Gallio.Framework.ComparisonSemantics.get_Default() in c:\Server\Projects\MbUnit v3.2\Work\src\Gallio\Gallio\Framework\ComparisonSemantics.cs:line 59
at MSpecSandBox4.When_Testing_Environment.<.ctor>b__0() in E:\Projects\2010\Presentations\BDD\MSpecSandBox4\TestConcern.cs:line 15
at Machine.Specifications.Model.Specification.InvokeSpecificationField() in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications\Model\Specification.cs:line 75
at Machine.Specifications.Model.Specification.Verify() in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications\Model\Specification.cs:line 53
at Machine.Specifications.Runner.Impl.SpecificationRunner.Run(Specification specification) in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications\Runner\Impl\SpecificationRunner.cs:line 25
at Machine.Specifications.Runner.Impl.SetupOnceContextRunner.RunSpecifications(Context context, ISpecificationRunListener listener, RunOptions options, IEnumerable1 resultSupplementers) in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications\Runner\Impl\ContextRunner.cs:line 55 at Machine.Specifications.Runner.Impl.SetupOnceContextRunner.Run(Context context, ISpecificationRunListener listener, RunOptions options, IEnumerable
1 globalCleanups, IEnumerable1 resultSupplementers) in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications\Runner\Impl\ContextRunner.cs:line 28 at Machine.Specifications.Runner.Impl.AssemblyRunner.RunContext(Context context, IEnumerable
1 globalCleanups, List1 supplements) in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications\Runner\Impl\AssemblyRunner.cs:line 78 at Machine.Specifications.Runner.Impl.AssemblyRunner.Run(Assembly assembly, IEnumerable
1 contexts) in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications\Runner\Impl\AssemblyRunner.cs:line 48
at Machine.Specifications.Runner.Impl.DefaultRunner.StartAssemblyRun(Assembly assembly, IEnumerable1 contexts) in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications\Runner\Impl\DefaultRunner.cs:line 112 at Machine.Specifications.Runner.Impl.DefaultRunner.StartRun(IDictionary
2 contextMap) in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications\Runner\Impl\DefaultRunner.cs:line 102
at Machine.Specifications.Runner.Impl.DefaultRunner.RunClass(MemberInfo member, Assembly assembly) in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications\Runner\Impl\DefaultRunner.cs:line 80
at Machine.Specifications.Runner.Impl.DefaultRunner.RunMember(Assembly assembly, MemberInfo member) in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications\Runner\Impl\DefaultRunner.cs:line 54
at Machine.Specifications.ReSharperRunner.Runners.RecursiveMSpecTaskRunner.Finish(TaskExecutionNode node) in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications.ReSharperRunner.4.1\Runners\RecursiveMSpecTaskRunner.cs:line 64
at JetBrains.ReSharper.TaskRunnerFramework.CurrentAppDomainHost.Execute(TaskExecutionNode node)
at JetBrains.ReSharper.TaskRunnerFramework.CurrentAppDomainHost.DoExecuteNodes(IEnumerable1 nodes) at JetBrains.ReSharper.TaskRunnerFramework.CurrentAppDomainHost.ExecuteNodes(IList
1 nodes)
at JetBrains.ReSharper.TaskRunnerFramework.TaskRunnerHostBase.ExecuteSerializedTree(String serializedTree)
at Gallio.Framework.Assertions.AssertionContext.Scope.ThrowFailureAccordingToBehavior(AssertionFailure failure) in c:\Server\Projects\MbUnit v3.2\Work\src\Gallio\Gallio\Framework\Assertions\AssertionContext.cs: line 287
at Gallio.Framework.Assertions.AssertionContext.Scope.SubmitFailure(AssertionFailure failure, Boolean noThrow) in c:\Server\Projects\MbUnit v3.2\Work\src\Gallio\Gallio\Framework\Assertions\AssertionContext.cs: line 244
at Gallio.Framework.Assertions.AssertionContext.SubmitFailure(AssertionFailure failure) in c:\Server\Projects\MbUnit v3.2\Work\src\Gallio\Gallio\Framework\Assertions\AssertionContext.cs: line 108
at Gallio.Framework.Assertions.AssertionHelper.Fail(AssertionFailure failure) in c:\Server\Projects\MbUnit v3.2\Work\src\Gallio\Gallio\Framework\Assertions\AssertionHelper.cs: line 107
at Gallio.Framework.Assertions.AssertionHelper.Verify(Func1 assertionFunc) in c:\Server\Projects\MbUnit v3.2\Work\src\Gallio\Gallio\Framework\Assertions\AssertionHelper.cs: line 93 at MbUnit.Framework.Assert.AreEqual(T expectedValue, T actualValue, EqualityComparison
1 comparer, String messageFormat, Object[] messageArgs) in c:\Server\Projects\MbUnit v3.2\Work\src\MbUnit\MbUnit\Framework\Assert.Comparisons.cs: line 108
at MbUnit.Framework.Assert.AreEqual(T expectedValue, T actualValue) in c:\Server\Projects\MbUnit v3.2\Work\src\MbUnit\MbUnit\Framework\Assert.Comparisons.cs: line 38
at MSpecSandBox4.When_Testing_Environment.<.ctor>b__0() in TestConcern.cs: line 15
at Machine.Specifications.Model.Specification.InvokeSpecificationField() in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications\Model\Specification.cs: line 75
at Machine.Specifications.Model.Specification.Verify() in E:\Projects\2008\Presentations\ThirdParty\mspec-src\mspec\Source\Machine.Specifications\Model\Specification.cs: line 53
When I installed the R# test runner for MSpec I got errors from the bat file. I imagine they probably aren't critical.
C:\Projects\bdd-test\packages\Machine.Specifications.0.4.24.0\tools>copy /y Mach
ine.Specifications.ReSharperRunner.6.0.pdb "C:\Users\chris\AppData\Roaming\JetB
rains\ReSharper\v6.0\vs10.0\Plugins" 1>NUL
When running mspec tests using the resharper test runner IAssemblyContext.OnAssemblyStart and IAssemblyContext.OnAssemblyComplete get called once per test.
I repro c# project of this issue can be downloaded here:
http://jobscalp.googlecode.com/files/mspecbug.zip
If you run the above code in the Resharper test runner it will fail, run it using mspec.exe and it will pass. I'm using VS2010 and Resharper 5.1
Ed.
I'd like to create a modified html template that allows for filtering specifications by concern as well as by tag. Is there anyway to specify the spark templates to use when generating the html report using mspec.exe?
Hi,
I experienced a little oddity recently when I was checking for the equality of two strings.
There seems to be an oversight in
Machine.Specifications.Utility.Internal.PrettyPrintingExtensions.GetFirstIndexOfFirstDifference(String actual, String expected)
When I run this test:
public class When_comparing_two_strings { static string _OnePointZeroZero; Establish context = () => _OnePointZeroZero = "1.00"; Because of = () => {}; It is_a_MachineSpec_bug_isnt_it = () => _OnePointZeroZero.ShouldEqual("1.0"); }
I am getting the following error:
System.IndexOutOfRangeException occurred Message=Index was outside the bounds of the array. Source=mscorlib StackTrace: at System.String.get_Chars(Int32 index) at Machine.Specifications.Utility.Internal.PrettyPrintingExtensions.GetFirstIndexOfFirstDifference(String actual, String expected)
In GetFirstIndexOfFirstDifference there is a check if "expected.Length" is lower than a counter
expected.Length < iand then, in the same line you're trying to get a value from the "expected" array:
expected[i] != actual[i]
Simple enough, that leads to an IndexOutOfRangeException. I suppose, the line should be:
if (expected.Length <= i || expected[i] != actual[i])
Best regards,
Steven
Hi,
The bat file puts the dll's in wrong place. At least it didn't work for me. Had to put them under Bin\Plugins instead.
//Daniel
Quick question. Why did you decide to develop your own assertion methods?
Why not use something that already exists, for example Should library (http://should.codeplex.com/)?
It would like that Subject specified in a base class would be applied also to the inherited specification.
For example, for such specifications, mspec runner will not display when_date_in_US_format specification in a "Parising date" specifications group, as I expect it to see.
[Subject("Parsing date")]
public class ParsingDateBaseSpec { }
public class when_date_in_US_format : ParsingDateBaseSpec { }
So i should repeat same subject for all inherited specifications, which is annoying.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.