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
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
Can anyone help me to run mocked test in CruiseControl.Net ?
asked by Gmoorick (2.3k 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 by scott (32k points)
0 votes
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 by Gmoorick (2.3k points)
0 votes
Too cool to be true 8)
Would you like us to publish it here?
answered by scott (32k points)
0 votes
OK, once I make it work with NCover I mail plugin to you.
answered by Gmoorick (2.3k points)
0 votes
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 FilesTypeMockTypeMock.NETmocking_on.bat"/>

<devenv>
<solutionfile>MyProject.sln</solutionfile>
<configuration>Debug</configuration>
<buildtype>Rebuild</buildtype>
<project>MyProject</project>
<executable>C:Program FilesMicrosoft Visual Studio 8Common7IDEdevenv.com</executable>
<buildTimeoutSeconds>600</buildTimeoutSeconds>
</devenv>

<nunit>
<path>C:Program FilesNUnit 2.4.3in unit-console.exe</path>
<assemblies>
<assembly>mytests.dll</assembly>
</assemblies>
</nunit>

But even with the call to mocking_on.bat, it fails.
answered by mikkoras (880 points)
0 votes
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 FilesTypeMockTypeMock.NetTMockRunner.exe C:Program FilesNUnit 2.4.3in
unit-console.exe
</path>...


Then NUnit will run in the context of TypeMock.
Let me know if you need more help.
answered by gilz (14.5k points)
0 votes
Thanks for the info. However, it didn't work from CruiseControl. From cmd, yes.

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

Test 1:
<path>C:Program FilesTypeMockTypeMock.NETTMockRunner.exe C:Program FilesNUnit 2.4.3in unit-console.exe</path>

Result:
<exception><![CDATA[System.IO.IOException: Unable to execute file [C:Program FilesTypeMockTypeMock.NETTMockRunner.exe C:Program FilesNUnit 2.4.3in unit-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 FilesTypeMockTypeMock.NETTMockRunner.exe "C:Program FilesNUnit 2.4.3in unit-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 FilesTypeMockTypeMock.NETTMockRunner.exe" "C:Program FilesNUnit 2.4.3in unit-console.exe" "C:MyProjectmytests.dll"

Result:
Success.

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

Test 4 (ccnet, with more quotes):
<path>"C:Program FilesTypeMockTypeMock.NETTMockRunner.exe" "C:Program FilesNUnit 2.4.3in unit-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 by mikkoras (880 points)
0 votes
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 by gilz (14.5k points)
0 votes
Plugin seems to work.

Thanks.
answered by mikkoras (880 points)
0 votes
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 by mikkoras (880 points)
...