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
We had to rollback Isolator on our build server back to version 5.4.5 because of the following problem:

1. Ugraded to Isolator 6.0.1 (also tried 6.0, same problem)
2. Developers' machines work fine, but developers don't have NCover 3.0 installed.
3. On a build machine we run a build that is triggered from CruiseControl.NET and includes full build followed by unit test execution with code coverage report generation.
4. Once the unit tests execution is complete for the first project, the build hangs forever at the point when it is supposed to generate code coverage report. Report is not generated.
5. Switching to Isolator 5.4.5 fixes the problem.

CruiseControl.NET has the following text in its log:

*** Internal Error mocked value not found
at de.a(...)
at de.a(...)
at TypeMock.MockManager.a(...)
at TypeMock.InternalMockManager.getReturn(...)
at System.ComponentModel.Component.Dispose(...)

In case we run the build without collecting code coverage, everything works fine.
asked by vagif (19.4k points)

16 Answers

0 votes
Vagif,

We had a few scattered reports of this issue, but it seems like you have the most detailed reproduction so far. Would you be able to send the full exception message with stack trace to our support email? In what stage of the build do you receive the exception?

Thanks,
Doron
Typemock Support
answered by doron (16.5k points)
0 votes
Doron,

Apparently, the exception that I described was unrelated to the hanging. It came from one of the tests and we don't have it for other projects that also hang the build. So there is very little log info I can give you. When it hangs it just stops after executing unit tests and prior generating coverage report. Diagnostics data at the point of stoppage don't look different: everything just stops.
answered by vagif (19.4k points)
0 votes
What sort of build script are you running?
answered by doron (16.5k points)
0 votes
Another question - is the code under test multithreaded?
answered by doron (16.5k points)
0 votes
No, none of the tests spawn additional threads. All tests are single-threaded.

I tried to paste here an extract from MsBuild script, but I was not able to properly paste XML. If you want full build script, I can mail it to you, but here's essential part (angle brackets removed):

    Exec Command="$(NCoverTool) $(NCoverToolOptions) $(NUnitTool) %(ProjectsToCover.FullPath) /xml:$(CCNetArtifactDirectory)\test-results\%(ProjectsToCover.Filename).xml //x $(CCNetArtifactDirectory)\coverage-results\%(ProjectsToCover.Filename).xml //a %(ProjectsToCover.AssemblyName)" ContinueOnError="true"
      Output TaskParameter="exitcode" ItemName="exitcodes"
    Exec
    NCoverReporting ToolPath="$(ProgramFiles)\NCover"
                     CoverageDataPaths="$(CCNetArtifactDirectory)\coverage-results\*.xml"
                     OutputPath="$(CCNetArtifactDirectory)\coverage-results\TotalCover.xml"
                     ReportFormat="Xml"
                     ReportType="MethodModuleNamespaceClass"
                     MergeFileName="$(CCNetArtifactDirectory)\coverage-results\MergedCover.xml"
answered by vagif (19.4k points)
0 votes
*** Internal Error mocked value not found
at de.a(...)
at de.a(...)
at TypeMock.MockManager.a(...)
at TypeMock.InternalMockManager.getReturn(...)


I just started to see this randomly in 6.0.2 / Visual Studio 2010. Re-running the test usually makes it go away. Not sure about the root cause yet.
answered by colinbo (1.8k points)
0 votes
colinbo,

Can you post a test that causes this?

Doron
Typemock Support
answered by doron (16.5k points)
0 votes
I got it randomly with 6.0.4.

Can't send a sample for the moment, but that's the stack trace I got:
at di.a(String A_0, Object A_1, String A_2, MethodBase A_3, Object[] A_4)
at di.a(Object A_0, String A_1, String A_2, MethodBase A_3, Object[] A_4, Object A_5)
at TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Boolean A_4, Boolean A_5, Object[] A_6)
at TypeMock.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected, Boolean isInterceptedType)
at MyClass.Finalize() in D:\Dev\Folder\MyClass.cs:line 44
answered by pierre-luc (3.3k points)
0 votes
Hi,
I've got <Internal> on v.6.0.4 today. In a test class I have 3 tests and the error is raised when the tests are executed one by one in some sequence. When I change execution order test runs fine.
answered by 3ter (2.5k points)
0 votes
I've investigated the problem a bit and here is what I've discovered.
Method, which I test:
public IEnumerable<SegmentedAccount> GetSegmentedAccounts(ISessionProxy session)
{
   Contract.Requires<ArgumentNullException>(null != session, "session");

   SegmentedAccount[] accountSegments;

   using (SqlCommand command = session.GetStoredProcCommand("sp_name"))
   {
      accountSegments = session.GetEntities<SegmentedAccount>(command).ToArray();
   }

   return accountSegments;
}

and 2 tests:

[TestMethod]
[Isolated]
public void GetBookkeepingAccountsCallsSP()
{
   SegmentedAccount[] segmentArr = new SegmentedAccount[1000];

   for (int i = 0; i < segmentArr.Length; i++)
   {
      segmentArr[i] = new SegmentedAccount()
      {
         IdBookkeepingAccount = i,
         IdBookkeepingAccountInstance = i,
         IdAccountDocumentRole = i / 250,
         Account = i.ToString("00000000000000000000"),
         IdSegment = i / 10,
         IdDocumentType = i / 40,
         IsnDocumentCurrency = new Guid("4E190DE1-A60F-44F5-AADA-0CB3AE965D88")
      };
   }

   // Create mocks
   ISessionProxy session = Isolate.Fake.Instance<ISessionProxy>();
   SqlCommand segCommand = Isolate.Fake.Instance<SqlCommand>();
   Isolate.WhenCalled(() => session.GetStoredProcCommand("EDoc.spx_getActualSegmentedAccounts")).WithExactArguments().WillReturn(segCommand);
   Isolate.WhenCalled(() => session.GetEntities<SegmentedAccount>(segCommand)).WithExactArguments().WillReturn(segmentArr);
   AccountDBAccessor accessor = new AccountDBAccessor();

   IEnumerable<SegmentedAccount> result = accessor.GetSegmentedAccounts(session).OrderBy(acc => acc.IdBookkeepingAccount);
   SegmentedAccount[] resultArr = result.ToArray();

   for (int i = 0; i < resultArr.Length; i++)
   {
      Assert.IsTrue(SegmentsEqual(segmentArr[i], resultArr[i]));
   }
}

[TestMethod]
[Isolated]
[DeploymentItem("AccountDBAccessor_GetBookkeepingAccounts.sql")]
public void IntegrationTest_GetBookkeepingAccounts()
{
   string userName = "IntegrationTest_GetBookkeepingAccounts";
   SqlDatabase db = new SqlDatabase(IntegrationTestsDBConnection.GetConnectionString());
   SessionProxy session = new SessionProxy(db);

   IUnityContainer container = Isolate.Fake.Instance<IUnityContainer>();
   IServerBasicConfiguration config = Isolate.Fake.Instance<IServerBasicConfiguration>();
   DBCommandExecutionHelper exec = new DBCommandExecutionHelper();
   AccountDBAccessor dbAccess = new AccountDBAccessor();

   // inject dependencies
   exec.Configuration = config;
   exec.DependencyContainer = container;
   session.Configuration = config;
   session.ExecHelper = exec;
   dbAccess.ExecHelper = exec;

   Isolate.WhenCalled(() => container.Resolve<ISessionProxy>()).WillReturn(session);
   Isolate.WhenCalled(() => session.Open(0, null)).CallOriginal();

   IEnumerable<SegmentedAccount> result;
   using (TransactionScope transactionContext = new TransactionScope())
   {
      session.Open(System.Data.IsolationLevel.ReadCommitted, userName);
      session.ExecuteNoQuery(new SqlCommand(File.ReadAllText("AccountDBAccessor_GetBookkeepingAccounts.sql")));

      result = dbAccess.GetSegmentedAccounts(session);
   }
   
   // verifications
   var segment = result.Where(seg => seg.IdBookkeepingAccount == 1 && seg.IdDocumentType == 1).Single();
   //...   
}


First test fills array with m=1000 elements. In this case one of the tests fails in 50% of runs. When m=100 no test runs fail. When m=1000 one of the test fails in 20% of runs

First test fails at row
IEnumerable<SegmentedAccount> result = accessor.GetSegmentedAccounts(session).OrderBy(acc => acc.IdBookkeepingAccount);

Second test fails at row
var segment = result.Where(seg => seg.IdBookkeepingAccount == 1 && seg.IdDocumentType == 1).Single();

In both cases error is *** Internal Error mocked value not found

Code coverage doesn't matter
Always second test in the test run fails
answered by 3ter (2.5k points)
...