Why do I get “Typemock is not enabled” when running tests?
This means the Typemock runner or profiler isn’t active.
- Run
TMockRunner.exebefore executing tests. - Make sure Visual Studio > Typemock Mocking is turned ON.
- If you’re using CI/CD, install Typemock or use the official build server Tasks for automatic deployment and license management.
- Check that your license is active for the local machine or build agent.
My tests fail after upgrading .NET. Is it supported?
Yes — the latest Typemock Isolator versions fully support modern .NET and C#.
👉 Download the latest version for guaranteed compatibility.
How do I mock static methods, sealed classes, or constructors?
Typemock lets you fake anything — even what other frameworks can’t:
Isolate.WhenCalled(() => MyStaticClass.DoWork()).WillReturn(true);
var fake = Isolate.Fake.NextInstance<MyService>();It works on statics, privates, constructors, events, and ref parameters — no code changes needed.
👉 See more examples in the Isolate API Reference
How do I test private methods or fields?
Invoke private methods:
Isolate.Invoke.Method(instance, "PrivateMethod");Set or get private fields:
Isolate.SetField(instance, "fieldName", newValue);
var value = Isolate.GetField(instance, "fieldName");Use sparingly — testing through public APIs is always cleaner.
How can I unit test legacy code without refactoring it?
That’s exactly why Typemock exists.
It isolates tightly coupled dependencies (statics, singletons, sealed classes) using patented runtime technology.
You can add tests without changing production code — and gradually refactor later for clarity.
How do I mock async methods or Tasks?
Isolate.WhenCalled(() => dependency.GetDataAsync())
.WillReturn(Task.FromResult(fakeData));
var result = await sut.DoWorkAsync();Avoid blocking calls (.Wait(), .Result) — async/await is fully supported in Isolator 9.x and above.
Can I mock DateTime.Now, Guid.NewGuid(), or Environment.MachineName?
Yes — Typemock can fake framework statics for deterministic tests:
Isolate.WhenCalled(() => DateTime.Now)
.WillReturn(new DateTime(2025, 1, 1));How do I test member variables vs behavior?
- Prefer behavior verification (
Isolate.Verify.WasCalled) over direct field checks. - If you must, use
Isolate.SetField()to manipulate internal state.
Behavior-based testing is safer and cleaner for refactoring.
Which test frameworks are supported?
MSTest, NUnit, and xUnit — all major .NET test runners integrate seamlessly with Typemock.
How do I enable Typemock in CI/CD (Azure, GitHub Actions, Jenkins)?
The best approach is to use Typemock’s native add-ins or build tasks, which automatically deploy Typemock on build agents and manage licenses.
Alternatively:
TMockRunner.exe -deploy
# after tests complete
TMockRunner.exe -unregister # introduced in v9.3.7This ensures licenses are cleaned up properly between builds.
Can I use Typemock in VS Code or Linux environments?
Yes — Typemock supports .NET 6+ cross-platform projects.
To use it in VS Code or Linux:
- Install the Typemock NuGet package.
- Run tests via:
tmockrunner dotnet test
Works on Windows, macOS, and most Linux distributions with .NET SDK 6+.
How does Typemock integrate with Visual Studio?
Typemock offers full Visual Studio integration, including:
- SmartRunner suggestions for missing tests
- Integration with MSTest, NUnit, and xUnit runners
- Automatic profiler activation
- Visual feedback on covered vs. uncovered code lines
Does Typemock slow down tests?
Barely. Typemock introduces minimal overhead at runtime.
To optimize performance:
- Disable verbose tracing and logs.
- Use partial fakes instead of full ones.
- Don't use coverage.
How can I measure and improve test coverage with Typemock?
Typemock includes its own coverage tool and integrates with:
- Microsoft Code Coverage
- JetBrains dotCover
- OpenCover
- Coverlet
Because Typemock lets you fake statics and privates, you can reach previously untestable paths — use this to close coverage gaps.
Focus on behavioral coverage, not just line count.
What patterns make Typemock tests maintainable?
✅ Follow Arrange-Act-Assert (AAA).
✅ Mock only dependencies, not logic.
✅ One assertion per test.
✅ Use Isolate.Verify for behavioral validation.
✅ Apply a three-part naming convention: Method_State_ExpectedResult.
Does Typemock support AI-based test suggestions?
Yes — the new AI Suggest analyzes your code to suggest missing tests and coverage gaps.
It automatically proposes tests for untested methods and helps maintain behavioral equivalence during refactoring.
👉 Learn more in the AI-Ready Isolator API.
How do I manage Typemock licenses in dynamic build agents (Azure, Docker, CI)?
Activate licenses automatically:
TMockRunner.exe -deploy -key <license>After build completion, unregister:
TMockRunner.exe -unregisterThis ensures floating licenses are released properly.
Azure DevOps Tasks now include auto-unregister for ephemeral agents.
How does Typemock actually intercept static and sealed calls?
Typemock uses patented technology that hooks directly into the .NET runtime (Profiler API) to redirect calls to your fakes.
No source changes, no re-compilation — pure runtime magic.
Can I use Typemock to test database, file, or network dependencies?
Yes — by mocking their APIs:
Isolate.WhenCalled(() => File.ReadAllText("data.txt"))
.WillReturn("mocked");This avoids hitting real resources and makes tests fast and repeatable.
How do I handle async tests that trigger external events?
Combine Typemock’s fakes with async test support:
Isolate.WhenCalled(() => _bus.PublishAsync(_)).IgnoreCall();
await sut.ExecuteAsync();
Isolate.Verify.WasCalledWithAnyArguments(() => _bus.PublishAsync(_));Ensures async calls are verified deterministically — no race conditions.
Typemock Isolator empowers .NET developers to:
- ✅ Mock anything (static, sealed, private, constructors)
- ✅ Test legacy code without refactoring
- ✅ Integrate with any test framework or CI/CD pipeline
- ✅ Run cross-platform (Windows, Linux, VS Code)
- ✅ Use AI-based test insights via Suggest