chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
I'm are currently having an issue with TypeMock 6.0.2 when running tests using TypeMock.Isolator.VisualBasic.

I'm running Windows 7 64 bit with Visual Studio 2010.

VB.Net code is compiled in .Net Framework v4.0.30319. I ran the test with VS Testrunner and also tried it with TestDriven.Net 3.0 RC.

This problem occured after I upgraded from TypeMock v5.3.1.0 to v6.0.2.0.

To reproduce the problem I've created a test based on the code found here: http://site.typemock.com/vbpage

Error message:
Test method TestProject3.UnitTest1.TestMethod_Isolator_Will_Fail threw exception:
System.MissingFieldException: Field not found: 'TypeMock.MockManager.q'.

Stack trace:
Typemock.Isolator.VisualBasic.IsolatedAttribute.Execute()
TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Boolean A_4, Object[] A_5)
TypeMock.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected)
TestProject3.UnitTest1.TestMethod_Isolator_Will_Fail() in D:ProjectsTestingTestProject3TestProject3UnitTest1.vb: line 16

Code sample:

Imports System.Text
Imports TypeMock.Isolator.VisualBasic
Imports Typemock

<TestClass()>
Public Class UnitTest1

Public Property TestContext() As TestContext

<TestMethod()> _
<Isolated()> _
Public Sub TestMethod_Isolator_Will_Fail()
Dim fakeProduct As Product = FakeInstance(Of Product)()

' Fake a return value
Using TheseCalls.WillReturn(100.0F)
fakeProduct.CalculatePrice(0)
Dim dummy As Single = fakeProduct.Price
End Using

Assert.AreEqual(fakeProduct.Price, 100.0F)
End Sub
End Class
Public Class Product
Public Sub CalculatePrice(ByVal value As Integer)
Price = value
End Sub
Public Property Price() As Single
End Class
asked by orjan (640 points)

10 Answers

0 votes
Hi,

I would like to verify the installation and referenced files are correctly placed.

Please verify the following:
1. Check in GAC folder that Typemock.dll is of version 6.0.2
2. Check the referenced Isolator dlls from the test project are of version 6.0.2

Regards,
Elisha,
Typemock Support
answered by Elisha (12k points)
0 votes
Hi,

1. Version in GAC is 6.0.2.
2. Referenced versions are also 6.0.2.

Regards,
Orjan
answered by orjan (640 points)
0 votes
I experience the same issue.

1. Yepp.
2. Yepp.

The failing tests is ONLY in the test class using the VB syntax from TypeMock.Isolator.VisualBasic. In this class I have ONE of 36 tests using this syntax, but ALL tests fail with the same issue as in the first post. If I comment out this one testt hat uses the Visual Basic syntax all remaining 35 tests pass. My test project has 509 unit test of which the majority uses TypeMock. Of all of these only the test class using the Visual Basic syntax has problems.

I'm using Windows 7 x64, Gallio 3.2.415 and TypeMock 6.0.2.
answered by halstein (8.7k points)
0 votes
Hi,

Thanks for the report, it seems like a bug. I'll investigate this issue and update you.

Regards,
Elisha,
Typemock Support
answered by Elisha (12k points)
0 votes
Hi,

I could not recreate this issue locally, and I suspect it may the result of an unsuccessful upgrade. Can you try to fully uninstall Isolator, verify the GAC is clean of Typemock assemblies, and re-install?

Thanks,
Doron
Typemock Support
answered by doron (17.2k points)
0 votes
I think it might be valuable to add that the referenced assemblies are the same version as the ones in the GAC, but they are not the same. The TypeMock assemblies are checked in to source controll together with the source code for our project. The assemblies checked in to source control are the ones being referenced. On our CI server TypeMock is not installed, but instead is auto deployed during the build process. The tests run fine on our CI server.

If I try to run the same command locally as on our CI server the tests fail. The command is: gallio.echo /runtime-version:v4.0.30319 /runner:TypeMock AssemblyUnderTest.Test.dll. However, if I uninstall TypeMock locally and instead "deploy" the TypeMock assemblies includeded with the project in source control the tests run fine.

Also, if I change the reference in the project to use the assemblies in the GAC the tests also run fine.

It seems like TypeMock gets confused when the installed assemblies are not located in the same place as the referenced assemblies, even though they are the same version.
answered by halstein (8.7k points)
0 votes
I found that not mixing TypeMock.Isolator.VisualBasic with the normal way of Typmocking in the same class makes it work.
answered by halstein (8.7k points)
0 votes
Hi,

You got it right in your previous post :)
The Isolator assemblies in your project should have the same version as Typemock.dll in the GAC.

Sorry I don't understand what you are saying here :oops:
Can you please explain the meaning of "mixing TypeMock.Isolator.VisualBasic with the normal way of Typmocking"?
answered by ohad (35.4k points)
0 votes
This will work:

Imports MbUnit.Framework
Imports Typemock.Isolator.VisualBasic
<TestFixture()>
Public Class LotsOfTests
   <Test(), Isolated()>
   Public Sub TestSomething
      Using TheseCalls.WillReturn(-1)
         'Do some stuff I want mocked
      End Using
      'Do some test stuff
   End Sub
End Class


This will not work:
Imports MbUnit.Framework
Imports TypeMock
Imports Typemock.Isolator.VisualBasic
<TestFixture()>
Public Class LotsOfTests
   <Test(), Isolated()>
   Public Sub TestSomething
      Using TheseCalls.WillReturn(-1)
         'Do some stuff I want mocked
      End Using
      'Do some test stuff
   End Sub
   <Test()>
   Public Sub TestSomethingTheNonVBWay
      MockManager.Init()
      Using recorder As New RecordExpectations
         'Do some stuff I want mocked
      End Using
      'Do some test stuff
      MockManager.Verify()
   End Sub
End Class


If I had these two ways of mocking in separate classes it would work, but together in the same class fails.
answered by halstein (8.7k points)
0 votes
Hi,

Just to make sure:

All the tests work fine if only VB API is used in the test?
Do you need to use the other API in you VB tests?

Regards,
Elisha,
Typemock Support
answered by Elisha (12k points)
...