23 Answers, 1 is accepted
There were some issues for SetupStatic , which is fixed now. Also, you can write the test like
[TestMethod, Description("Ticket")]
public void ShouldMockCallReturningInstanceForTheClass()
{
Mock.Arrange(() => MyTest.Parse("2")).Returns(new MyTest());
var ret = MyTest.Parse("2");
Assert.NotNull(ret);
}
Here , i havent used the SetupStatic call , but rather it will be mocked on deman during Mock.Arrange(). Also, please make sure your JM profier / addin is not disabled while mocking static features.
Addtionally, if you need a new build urgently please let me know, and provide me an email. I'll send it back to you.
Regards,
Mehfuz

[TestMethod] |
public void JustMock_Test() |
{ |
// Arrange |
var foo = Mock.Create<Foo>(); |
Mock.Arrange(() => foo.Echo(1)).Returns(1).MustBeCalled(); |
Mock.Arrange(() => foo.Echo(2)).Returns(2); |
// Act |
var actual1 = 0; |
var actual2 = 0; |
actual1 = foo.Echo(1); |
actual2 = foo.Echo(2); |
// Assert |
Assert.AreEqual(1, actual1); |
Assert.AreEqual(2, actual2); |
Mock.Assert(foo); |
} |
public class Foo |
{ |
internal int Echo(int p) |
{ |
return 99; |
} |
} |
Accoring to your example, your expected call is internal. The build which is out there, dont support internal calls. We are shipping nonpublic mocking with the upcoming build.
I can send you a preview build if urgent, but for that you have to provide me with any drop address.
Regards,
Mehfuz.

That is very odd, can you plese check that after installing justmock , the examples are working properly. You will find similar tests under Elevated \FinalFixture , StaticFixture.cs. Examples can be found at %PROGRAM_FILES%\Telerik\JustMock\Examples.
Regards
Mehfuz


Failed ShouldCreateMockForSealedInternal Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.SealedFixture.ShouldCreateMockForSealedInternal threw exception: ... |
Failed ShouldAssertCall Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.StaticFixture.ShouldAssertCall threw exception: ... |
Failed ShouldCancelSqlConnectionOpen Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.Regression.SqlConectionTest.ShouldCancelSqlConnectionOpen threw exception: ... |
Failed ShouldAssertGenericArgumentAsReturn Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.FinalFixture.ShouldAssertGenericArgumentAsReturn threw exception: ... |
Failed ShouldAssertCustomValueForDateTime Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.MsCorlibFixture.ShouldAssertCustomValueForDateTime threw exception: ... |
Failed ShouldAssertExtensionMethodWithArguments Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.ExtentionMethodFixture.ShouldAssertExtensionMethodWithArguments threw exception: ... |
Failed ShouldAssertStaticCalls Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.StaticFixture.ShouldAssertStaticCalls threw exception: ... |
Failed ShouldAssertFinalCalls Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.SealedFixture.ShouldAssertFinalCalls threw exception: ... |
Failed ShouldAssertStaticGetOnProperty Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.StaticFixture.ShouldAssertStaticGetOnProperty threw exception: ... |
Failed ShouldAssertInvokedPartialCalls Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.PartialMockFixture.ShouldAssertInvokedPartialCalls threw exception: ... |
Failed ShouldAssertPropertyGet Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.FinalFixture.ShouldAssertPropertyGet threw exception: ... |
Failed ShouldVerifyCallOnPropertySet Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.StaticFixture.ShouldVerifyCallOnPropertySet threw exception: ... |
Failed ShouldAssertFakeItemsAssignedWithWhereClauseFromUserQuery Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.LinqFixture.ShouldAssertFakeItemsAssignedWithWhereClauseFromUserQuery threw exception: ... |
Failed ShouldMockConstraintMethodWithReturnReturnsASealedClassMock Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.Regression.MiscFixture.ShouldMockConstraintMethodWithReturnReturnsASealedClassMock threw exception: ... |
Failed ShouldAssertMocks Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.MsCorlibFixture.ShouldAssertMocks threw exception: ... |
Failed ShouldThrowProperExceptionForPartailsThatAreNotInvokedDuringAssertion Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.PartialMockFixture.ShouldThrowProperExceptionForPartailsThatAreNotInvokedDuringAssertion threw exception: ... |
Failed ShouldAssertArrangeOnStatic Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.StaticFixture.ShouldAssertArrangeOnStatic threw exception: ... |
Failed ShouldAssertInterfaceExtentensionMethodCall Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.ExtentionMethodFixture.ShouldAssertInterfaceExtentensionMethodCall threw exception: ... |
Failed ShouldAssertCallWithAReturn Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.MsCorlibFixture.ShouldAssertCallWithAReturn threw exception: ... |
Failed ShouldAssertCustomEventCall Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.FinalFixture.ShouldAssertCustomEventCall threw exception: ... |
Failed ShouldAssertReturnValueWhereTypeInheritedFromClass Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.FinalFixture.ShouldAssertReturnValueWhereTypeInheritedFromClass threw exception: ... |
Failed ShouldAssertCallOriginal Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.FinalFixture.ShouldAssertCallOriginal threw exception: ... |
Failed ShouldMockMethodWithConstraintGeneric Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.FinalFixture.ShouldMockMethodWithConstraintGeneric threw exception: ... |
Failed ShouldVerifyPropertySet Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.FinalFixture.ShouldVerifyPropertySet threw exception: ... |
Failed ShouldAssertActions Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.FinalFixture.ShouldAssertActions threw exception: ... |
Failed ShouldAssertExtentionMethodWithMultipleArguments Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.ExtentionMethodFixture.ShouldAssertExtentionMethodWithMultipleArguments threw exception: ... |
Failed ShouldMockCurrentHtppContext Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.Regression.HttpContextTest.ShouldMockCurrentHtppContext threw exception: ... |
Failed ShouldMockClassWithGenericArguments Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.FinalFixture.ShouldMockClassWithGenericArguments threw exception: ... |
Failed ShouldAssertArrangeOnGenericCalls Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.FinalFixture.ShouldAssertArrangeOnGenericCalls threw exception: ... |
Failed ShouldMockClassHavingWithSubConstraints Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.Regression.MiscFixture.ShouldMockClassHavingWithSubConstraints threw exception: ... |
Failed ShouldAssertGenericCalls Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.FinalFixture.ShouldAssertGenericCalls threw exception: ... |
Failed ShouldAssertPartilalMethodSetup Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.StaticFixture.ShouldAssertPartilalMethodSetup threw exception: ... |
Failed ShouldAssertFinalMethodSetups Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.FinalFixture.ShouldAssertFinalMethodSetups threw exception: ... |
Failed ShouldAssertRefArg Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.FinalFixture.ShouldAssertRefArg threw exception: ... |
Failed ShouldAssertOriginalReturnForCallOriginal Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.FinalFixture.ShouldAssertOriginalReturnForCallOriginal threw exception: ... |
Failed ShouldThrowForInvalidAssertion Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.StaticFixture.ShouldThrowForInvalidAssertion threw exception: ... |
Failed ShouldMockInstanceCallPartially Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.PartialMockFixture.ShouldMockInstanceCallPartially threw exception: ... |
Failed ShoulAssertSetupOnMethodWithNestedGenConstraints Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.Regression.MiscFixture.ShoulAssertSetupOnMethodWithNestedGenConstraints threw exception: ... |
Failed ShouldAssertSetupCalls Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.MsCorlibFixture.ShouldAssertSetupCalls threw exception: ... |
Failed ShoudldMockMethodWithParameterTypeDefinedFromClassGenType Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.Regression.MiscFixture.ShoudldMockMethodWithParameterTypeDefinedFromClassGenType threw exception: ... |
Failed ShouldAssertGenericArgumentWithClassForAction Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.FinalFixture.ShouldAssertGenericArgumentWithClassForAction threw exception: ... |
Failed ShouldMockHttpContext Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.Regression.HttpContextTest.ShouldMockHttpContext threw exception: ... |
Failed ShouldAssertGenericOutArguments Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.FinalFixture.ShouldAssertGenericOutArguments threw exception: ... |
Failed ShouldThrowExceptionForNotInovkedSetForMustBeCalled Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.Regression.MiscFixture.ShouldThrowExceptionForNotInovkedSetForMustBeCalled threw exception: ... |
Failed ShouldMockStaticFileOperation Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.MsCorlibFixture.ShouldMockStaticFileOperation threw exception: ... |
Failed ShouldMockExtentionMethod_ThirdParty Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.ExtentionMethodFixture.ShouldMockExtentionMethod_ThirdParty threw exception: ... |
Failed ShouldAssertGenericOutWithDefault Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.FinalFixture.ShouldAssertGenericOutWithDefault threw exception: ... |
Failed ShouldAssertOutArg Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.FinalFixture.ShouldAssertOutArg threw exception: ... |
Failed ShouldBeAbleToMockStaticClass Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.StaticFixture.ShouldBeAbleToMockStaticClass threw exception: ... |
Failed ShouldTreatSetupsForTwoDifferentInstancesDifferently Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.FinalFixture.ShouldTreatSetupsForTwoDifferentInstancesDifferently threw exception: ... |
Failed ShouldAssertExtensions Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.ExtentionMethodFixture.ShouldAssertExtensions threw exception: ... |
Failed ShouldAssertStrictMockingOnStatic Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.StaticFixture.ShouldAssertStrictMockingOnStatic threw exception: ... |
Failed ShouldAssertGenericValueTypeArg Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.FinalFixture.ShouldAssertGenericValueTypeArg threw exception: ... |
Failed ShouldAssertOverloads Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.FinalFixture.ShouldAssertOverloads threw exception: ... |
Failed ShouldMockStaticFileForReadOperaton Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.MsCorlibFixture.ShouldMockStaticFileForReadOperaton threw exception: ... |
Failed ShouldAssertArrange Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.FinalFixture.ShouldAssertArrange threw exception: ... |
Failed ShouldArrangeStaticCallsDirectly Telerik.JustMock.Tests.VS2010 Test method Telerik.JustMock.Tests.Elevated.PartialMockFixture.ShouldArrangeStaticCallsDirectly threw exception: ... |
It means all your proifler related tests are failing. Therefore, here is the troubleshooting:
1. Do you have any profiler related tools installed in your visual studio Ex. Typemock, Dottrace or some other that is setting the COR_PROFILER variable before JM. This can interfere with JM profiler and make your tests fail.
2. Are you using a localized version of Visual studio ? We fixed it , but not released yet.
3. If 1 and 2 is NO , then try re-installing the JM
Since, profiler is not working, any tests with static or final methods will fail. But other tests with interface , virtual ,etc will still pass because they dont use profiler, they use proxy instead.
Hope that helps,
Mehfuz.


@David , nice that things are working for you, We are woking on the dottrace integration , hopefully it will be out there sometime.
@Burton : Please make sure that in the build machine you dont have any other profiler related tools or TypeMock installed. Also, if you are running the tests in automated build, you need to use the MSBuild task that came with the JM distribution. Also, is your all profiler related tests are failing ? If NO, try sending me an email at mehfuz.hossain att telerik.com i can provide you with a build.
Hope that helps,
Mehfuz

Could you provide more information on how you're running the automated builds on your build server?
You mentioned "TFS build machine" in one of your previous posts and that suggests to me you're using Team Build to run your automated tests. Could you please verify whether this is correct?
If you're using Team Build this means you're actually using MSBuild. In the Source Control Explorer you could take a look under your project's root folder (e.g. $/MyProject). There you should find the following folder: TeamBuildTypes/[The name of your build].
There you should find a file named TFSBuild.proj.
This is the MSBuild responsible for your build and you could apply the approach mentioned here:
http://www.telerik.com/help/justmock/integration-msbuild-tasks.html
Hope this information helps.
Kind regards,
Chris
the Telerik team

I see. Yes, the situation with Team Build 2010 is a little bit different. Sorry for misleading you with my previous post.
We haven't provided yet a workflow activity which you could easily drag and drop into you process template but we'll do that soon. For now you could use the following work around to make your tests aware of JustMock's profiler:
1) First select your build in Team Explorer, right click it and select "Edit Build Definition".
Then go to the "Process" category and click the "Show details" expander.
Then click on the template (the xaml file) to open it. You could also first go to the respective folder in source control and branch it.

2) Then in the workflow designer go to the "Run Tests" sequence.

3) From VS Toolbox drag three times the InvokeMethod primitive activity right in the beginning of the Run Tests sequence.

4) Set the following properties for each InvokeMethod activity:
TargetType: System.Environment
MethodName: SetEnvironmentVariable
and then add two string parameters for each InvokeMethod.
5) For the first InvokeMethod's parameters set the following values:
"COR_ENABLE_PROFILING", "0x1"
for the second method set:
"COR_PROFILER", "{D1087F67-BEE8-4f53-B27A-4E01F64F3DA8}"
and for the third method set:
"COMPLUS_ProfAPI_ProfilerCompatibilitySetting", "EnableV2Profiler"
6) Finally your Run Tests sequence should look like this:

7) Check-in the .xaml file and run the build.
I tested this locally and it worked fine. I hope this will work fine for you too.
Should you have some other questions or problems, please don't hesitate to contact us.
Kind regards,
Chris
the Telerik team


Thanks for bringing up the question.
Unfortunately, the above is still the way of configuring test environment for JustMock in Team Build 2010 but we are working on it and soon we will provide a CodeActivity workflow for JustMock that will consolidate the steps.
Kind Regards,
Mehfuz
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

This still the standard way of configuring test environment for JustMock in Team Build 2010 ?
Thanks again for bringing up the question.
Now, you can configure JustMock using the code activity workflow component that you can find under %Program_Files%\Teleirk\JustMock\Libraries folder in most recent releases. I would also request you to take a look into the following post for more detail on how to set it up:
http://www.telerik.com/help/justmock/integration-code-activity-workflow.html
Kind Regards
Ricky
the Telerik team
Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

I tried to follow that article on modifying the DefaultBuildTemplate.xaml by adding the JustMockTestRunner in replace of the 3 MSTest calls that are referenced in the article.
My issue is that even though I configure my build controller properties to point to the new JustMock assemblies and get the just mock test runner in my toolbox. When I try and drag and drop the new JustMockTestRunner from the tool box into the design surface of the DefaultBuildTemplate.xaml a "X" is shown that it isn't possible and when I "drop" it doesn't add the item to the design surface.
I created a support ticket but if you have any ideas feel free to reply..
Thanks,
Chris

make sure to follow these steps from the doc:
BTW, the solution mentioned here could be any solution, you can create a new one if you want.
Continue by adding a new class library project to your Solution. To modify the build template you need to include it in the project you created, using the "Add as Link" option and after that set its build action to none. If you are new to TFS, the DefaultTemplate is a xaml file where the activity is dropped. You can find it under the BuildProcessTemplates folder of your TFS:
In order to drag/drop the JustMockTestRunner activity to your build template, you have to add a reference to the Telerik.JustMock.Build.Workflow.dll assembly
Thanks again for contacting us. Also thanks to Jonathan for jumping in. In order to drag / drop the activity to build template please further confirm the following steps:
1. Create a class library project
2. Add a reference to Telerik.JustMock.Build.Workflow.DLL to the project.
3. Add a link to the build template file and don't forget to set the build action to none (not required).
In addition, make sure that you have removed the existing Run MSTest activities.
Let me know if you still facing issues.
Kind Regards
Ricky
the Telerik team
Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.