Mocking an async calls alse triggers hidden mocking of the return type. Depending of the type it might cause unexpected behavior or exception.
MbUnitContextResolver gets wrongly initialized because of the weak check based on Gallio.Framework.Assertions.AssertionException type presence in the current app domain. Needs to be improved with some additional type check from mbunit assembly, MbUnit.Framework.TestFixtureAttribute for example.
The main point behind this request is to add new command line option to JustMockRunner in order to enable profiler without need for being registered, more details about this feature can be found on MSDN at https://msdn.microsoft.com/en-us/library/ee471451(v=vs.100).aspx
Docker is a container acting like an isolated environment. Research how the JustMock profiler can be registered into such container. Hosted VSTS should work on the same principle. Research how the registry could be accessed through VSTS extension or other tools.
AxoCover is test runner and a code coverage tool. https://marketplace.visualstudio.com/items?itemName=axodox1.AxoCover https://github.com/axodox/AxoCover
Asynchronous test execution might be run in a separate thread (it depends of the environment and it is completely transparent) which causes arrangements to lose their context. That is why the expected mocked return value for DateTime.UtcNow calls the original code and finally the test fails.
There is a different behaviour when mocking the same method using the following two Arrange overrides: public static FuncExpectation<TResult> Arrange<TResult>(Expression<Func<TResult>> expression); public static FuncExpectation<TResult> Arrange<T, TResult>(T obj, Func<T, TResult> func); Repro project attached. Steps to reproduce: 1. Open attached solution 2. In Tests.cs, run JustMockArrangeQueryableTest - it passes 3. Run JustMockArrangeQueryableTest2 - it fails with a invalid cast exception on the Residents collection.
I am using Visual Studio 2015, Crystal Reports 12.0.2. When running from Visual Studio in debug mode or not, the application hangs on the statement "new ReportDocument()". ReportDocument is a class defined in CrystalReports. When I disabled the JustMock Profiler, this statement no longer hung. Just FYI. Hopefully others will see this.
If I define a fluent API, I might have an interface such as this: public interface IRegistrar { IRegistrar UsingThis(object someThing); IRegistrar UsingThat<TThatThing>() } If I create a mock of this using the default Behaviour.RecursiveLoose and make no arrangements, calls to the methods will return new mocks of the type, rather than the same instance that was called. It would be nice to have a behaviour type that can return the same instance (in this case the mocked instance) without having to define a stub for each method call. My code under test might look like: IRegistrar reg; reg .UsingThis(new object()) .UsingThat<int>(); Currently, a test on the second call will fail if written against the mock assigned to 'reg'.
Our team is moving to VSTS and not having an official solution to run JustMock tests through their build system is a deal-breaker.
I have logging class which are using everywhere. I want to Mock this class for all tests. And i tried to use AssemblyInitialize but got problem. I have simulated this problem with JustMock.ElevatedExamples.AdvancedUsage examples: 1) Add BaseTest class [TestClass] public class BaseTest { [AssemblyInitialize()] public static void AssemblyInit(TestContext context) { Mock.SetupStatic(typeof(Common1), StaticConstructor.Mocked); // Arranging: When the static(Foo.FooProp_GET) property is called, it should return expected. var fakeUsed = Mock.Create<LogWriter1>(Constructor.Mocked); Mock.Arrange(() => Common1.Log).Returns(fakeUsed); } [AssemblyCleanup] public static void Cleanup() { //clean up stuff here } } public static class Common1 { static Common1() { Log = new LogWriter1(); } public static LogWriter1 Log { get; set; } } public class LogWriter1 { } 2) When run test from VS - all ok 3) When run from command line it is not working. Show Message box "Process Starts Now". SET JUSTMOCK_INSTANCE=1 SET COR_ENABLE_PROFILING=1 SET COR_PROFILER={B7ABE522-A68F-44F2-925B-81E7488E9EC0} "C:\Program Files (x86)\Telerik\JustMock\Libraries\JustMockRunner.exe" "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\MSTest.exe" /testcontainer:"D:\test\CSExamples\JustMock.ElevatedExamples\bin\Debug\JustMock.ElevatedExamples.dll" How i can mock logger for all test? It is static public property. I use MS Test + VS 2015.
It would be good if we could use named parameters inside Mock.Arrange method.
When using Mock.CreateLike<> we've found that trying to directly mock anything lower than two layers down on a concrete class (e.g. x => x.Layer1.Layer2.Property == "test") throws a NullReferenceException unless the profiler is enabled. It wasn't clear in the exception or the documentation relating to this method that the real issue was the profiler being disabled, and only by trial and error did we find the solution.
Tests fail when run with vstest.console.exe but pass when run from VS2015. Findings: The problematic scenario includes reference to Microsoft.WindowsAzure.ServiceRuntime.dll and usage of the RoleEnvironment class. When the RoleEnvironment class is used in a test project without JustMock and runned from vstest.console the exception will be thrown as well. Here is the exact exception: System.TypeInitializationException: The type initializer for 'Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment' threw an exception. ---> System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> <CrtImplementationDetails>.ModuleLoadException: The C++ module failed to load while attempting to initialize the default appdomain. ---> System.Runtime.InteropServices.COMException: Invalid operation. (Exception from HRESULT: 0x80131022) Stack Trace: at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) at <CrtImplementationDetails>.GetDefaultDomain() at <CrtImplementationDetails>.DoCallBackInDefaultDomain(IntPtr function, Void* cookie) at <CrtImplementationDetails>.LanguageSupport.InitializeDefaultAppDomain(LanguageSupport* ) at <CrtImplementationDetails>.LanguageSupport._Initialize(LanguageSupport* ) at <CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* ) --- End of inner exception stack trace --- at <CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* ) at .cctor() --- End of inner exception stack trace --- at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeEnvironment() at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment..cctor() --- End of inner exception stack trace --- at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.get_IsAvailable() Workaround: the vstest.console.exe could be started with parameter /InIsolation, which runs the tests in an isolated process. Here is the link to the command line options: https://msdn.microsoft.com/en-us/library/jj155796.aspx
I want to check the order of methode calls but InSequence() does not work for it.
Resharper 10 code coverage have tests failing when arrange to have JustMock to return values from methods called under test. Perhaps one tool too many manipulating .NET objects behind-the-scenes at a time?
My team and I have spotted some odd behaviour with the latest version of JustMock (2015.3.929.5) when targeting a Windows Store app. If we create a mock for an object in a helper method, the mock fails when making assertions for calls to the mock. The following code illustrates the issue: [TestMethod] public void ThisWillFail() { var subject = CreateSubject(); subject.DoSomething(); subject.Assert(s => s.DoSomething(), Occurs.Once()); } [TestMethod] public void ThisWillPass() { var subject = Mock.Create<ISubject>(); subject.DoSomething(); subject.Assert(s => s.DoSomething(), Occurs.Once()); } public interface ISubject { void DoSomething(); } private static ISubject CreateSubject() { return Mock.Create<ISubject>(); } In this code, the first test will fail but the second test will pass. The only difference is that, in the first test, we're setting up the mock in a helper method. We have a "Unit Test Library (.NET for Windows Store apps)" referencing the Telerik.JustMock assembly. I have attached a simple project containing this implementation. It's worth noting that the same code passes in a regular .NET class library; it only fails in a "Unit Test Library (.NET for Windows Store apps)". It's also worth noting that this worked under an older version of the assembly (2014.3.1021.2). Any help would be appreciated, as we currently have around 3,000 tests and a good proportion of them set up their mocks using a helper method in this way. Regards William Cowell