Welcome to Typemock Answers. Here you can ask and receive answers from other community members. And if you liked or disliked an answer or thread: react with an up- or downvote Enjoy!

TypeMock and CruiseControl

+1 vote
Can anyone help me to run mocked test in CruiseControl.Net ?
asked Nov 20, 2006 by Gmoorick (520 points)

13 Answers

0 votes
You can run tests using MSBuild Tasks or nant, and have CC.NET run those tests, but we don't currently have direct support through CruiseControl.NET.
We already have that feature request but as the CC.NET documents don't advise on using the internal nunit task, it has a low priority
answered Nov 20, 2006 by scott (29,080 points)
+1 vote
I'm too lazy to implement MSBuild or NAnt :)
So I've made a task plugin for CruiseControl.Net that runs Nunit with TMockRunner. NCover is on the way ;)
answered Nov 21, 2006 by Gmoorick (520 points)
0 votes
Too cool to be true 8)
Would you like us to publish it here?
answered Nov 21, 2006 by scott (29,080 points)
+1 vote
OK, once I make it work with NCover I mail plugin to you.
answered Nov 21, 2006 by Gmoorick (520 points)
+1 vote
So, I have the following setup: CruiseControl, nUnit and TypeMock.

The nUnit tests are testing methods that call methods which are TypeMocked. If I run the tests from the nUnit user interface, everything goes ok.

However, if I let CruiseControl do the compiling and calling nUnit, I get the following error:
*** TypeMock.NET is not enabled, to enable do one of the following:
1. run 'mocking_on.bat' before running the tests
2. run tests via TMockRunner.exe
3. use TypeMockStart tasks for MSBuild or NAnt
4. set Tools->Enable TypeMock.NET from within Visual Studio

How do I enable TypeMock when running the build and tests from CruiseControl?

I tried this kind of ccnet.config:
<exec executable="C:\Program Files\TypeMock\TypeMock.NET\mocking_on.bat"/>

<devenv>
<solutionfile>MyProject.sln</solutionfile>
<configuration>Debug</configuration>
<buildtype>Rebuild</buildtype>
<project>MyProject</project>
<executable>C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.com</executable>
<buildTimeoutSeconds>600</buildTimeoutSeconds>
</devenv>

<nunit>
<path>C:\Program Files\NUnit 2.4.3\bin\nunit-console.exe</path>
<assemblies>
<assembly>mytests.dll</assembly>
</assemblies>
</nunit>

But even with the call to mocking_on.bat, it fails.
answered Jan 10, 2008 by mikkoras (550 points)
+1 vote
Hi,

In order for tests to use Typemock, they have to run in a context. In your case, the best way to go is to use TMockRunner. It is an executable, residing in the Typemock installation directory. In the simple case it doesn't take any parameters, other than, in your case, the NUnit path and parameters.

Here's a link to CCNet plug-in Gmoorick has developed:
https://www.typemock.com/community/viewtopic.php?t=380

Without the plug-in, you can do this: In the NUnit part of the CCNet file, replace the path with the following (using TMockRunner real installation location):
<nunit> 
<path> C:\Program Files\TypeMock\TypeMock.Net\TMockRunner.exe C:\Program Files\NUnit 2.4.3\bin\nunit-console.exe
</path>...


Then NUnit will run in the context of TypeMock.
Let me know if you need more help.
answered Jan 10, 2008 by gilz (20,200 points)
+1 vote
Thanks for the info. However, it didn't work from CruiseControl. From cmd, yes.

*******************

Test 1:
<path>C:\Program Files\TypeMock\TypeMock.NET\TMockRunner.exe C:\Program Files\NUnit 2.4.3\bin\nunit-console.exe</path>

Result:
<exception><![CDATA[System.IO.IOException: Unable to execute file [C:\Program Files\TypeMock\TypeMock.NET\TMockRunner.exe C:\Program Files\NUnit 2.4.3\bin\nunit-console.exe]. The file may not exist or may not be executable. ---> System.ComponentModel.Win32Exception: The filename, directory name, or volume label syntax is incorrect
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at ThoughtWorks.CruiseControl.Core.Util.ProcessExecutor.RunnableProcess.StartProcess()
--- End of inner exception stack trace ---
at ThoughtWorks.CruiseControl.Core.Util.ProcessExecutor.RunnableProcess.StartProcess()
at ThoughtWorks.CruiseControl.Core.Util.ProcessExecutor.RunnableProcess.Run()
at ThoughtWorks.CruiseControl.Core.Util.ProcessExecutor.Execute(ProcessInfo processInfo)
at ThoughtWorks.CruiseControl.Core.Tasks.NUnitTask.Run(IIntegrationResult result)
at ThoughtWorks.CruiseControl.Core.Project.RunTasks(IIntegrationResult result, IList tasksToRun)
at ThoughtWorks.CruiseControl.Core.Project.Run(IIntegrationResult result)
at ThoughtWorks.CruiseControl.Core.IntegrationRunner.Build(IIntegrationResult result)]]></exception>

*******************

Test 2 (with quotes)
<path>C:\Program Files\TypeMock\TypeMock.NET\TMockRunner.exe "C:\Program Files\NUnit 2.4.3\bin\nunit-console.exe"</path>

Result:
<exception><![CDATA[System.ArgumentException: Illegal characters in path.
at System.IO.Path.CheckInvalidPathChars(String path)
at System.IO.Path.Combine(String path1, String path2)
at ThoughtWorks.CruiseControl.Core.Util.ProcessInfo.RepathExecutableIfItIsInWorkingDirectory()
at ThoughtWorks.CruiseControl.Core.Util.ProcessInfo..ctor(String filename, String arguments, String workingDirectory)
at ThoughtWorks.CruiseControl.Core.Tasks.NUnitTask.NewProcessInfo(String outputFile, IIntegrationResult result)
at ThoughtWorks.CruiseControl.Core.Tasks.NUnitTask.Run(IIntegrationResult result)
at ThoughtWorks.CruiseControl.Core.Project.RunTasks(IIntegrationResult result, IList tasksToRun)
at ThoughtWorks.CruiseControl.Core.Project.Run(IIntegrationResult result)
at ThoughtWorks.CruiseControl.Core.IntegrationRunner.Build(IIntegrationResult result)]]></exception>

*******************

Test 3 (from command line):
C:\>"C:\Program Files\TypeMock\TypeMock.NET\TMockRunner.exe" "C:\Program Files\NUnit 2.4.3\bin\nunit-console.exe" "C:\MyProject\mytests.dll"

Result:
Success.

*******************

Test 4 (ccnet, with more quotes):
<path>"C:\Program Files\TypeMock\TypeMock.NET\TMockRunner.exe" "C:\Program Files\NUnit 2.4.3\bin\nunit-console.exe"</path>

Result:
System.ArgumentException: Illegal characters in path. at System.IO.Path.CheckInvalidPathChars(String path) at System.IO.Path.Combine(String path1, String path2) at ThoughtWorks.CruiseControl.Core.Util.ProcessInfo.RepathExecutableIfItIsInWorkingDirectory() at ThoughtWorks.CruiseControl.Core.Util.ProcessInfo..ctor(String filename, String arguments, String workingDirectory) at ThoughtWorks.CruiseControl.Core.Tasks.NUnitTask.NewProcessInfo(String outputFile, IIntegrationResult result) at ThoughtWorks.CruiseControl.Core.Tasks.NUnitTask.Run(IIntegrationResult result) at ThoughtWorks.CruiseControl.Core.Project.RunTasks(IIntegrationResult result, IList tasksToRun) at ThoughtWorks.CruiseControl.Core.Project.Run(IIntegrationResult result) at ThoughtWorks.CruiseControl.Core.IntegrationRunner.Build(IIntegrationResult result)

Any ideas?
answered Jan 10, 2008 by mikkoras (550 points)
+1 vote
Hi,

Thanks for the outputs. It is possible to run a batch file from the command line, as an option.

I've updated the former post - please check out the CCNet plug-in for Typemock:
https://www.typemock.com/community/viewtopic.php?t=380

The plug-in is what you are looking for. Let me know how it works out.
answered Jan 10, 2008 by gilz (20,200 points)
+1 vote
Plugin seems to work.

Thanks.
answered Jan 10, 2008 by mikkoras (550 points)
+1 vote
Since TypeMock enabling in CruiseControl requires the usage of the <TMockRunner> element, doesn't basically prevent execution of both typemocked and non-typemocked test cases if either the <TMockRunner> or <nunit> tasks fails?

Example of a CruiseControl.net script:

<devenv>
...
</devenv>

<TMockRunner>
...
</TMockRunner>

<nunit>
...
</nunit>

So, if for example the test cases executed inside the <TMockRunner> task fail, it means that the test cases in the <nunit> task won't be executed.

Is there any way get both <TMockRunner> and <nunit> test case tasks to be executed always and the total outcome of those two tasks determine if the next task should be executed.

Hmm... I wonder if that was clear enough...


Mikko
answered Feb 12, 2009 by mikkoras (550 points)
...