We have been writing specifications for our JavaScript business logic using Jasmine. We're able to run our test suite within a browser, but how would we integrate this within TeamCity? Preferrably we do not want to use NodeJS, rather something as simple as possible.
I have created a modified version of run-jasmine.js that is found in the PhantomJS sources (original version is here. This version can be used within TeamCity (it will automatically detect that it is running in TeamCity). This updated version is using TeamCity service messages which allows for a nice integration.
You will need PhantomJS. You'll also need one of the following:
run-jasmine.js (for Jasmine 1.x).
run-jasmine.js (for Jasmine 2.x).
Add a build step in your TeamCity build configuration that can run this step:
phantomjs.exe run-jasmine.js index.html
index.html is your Jasmine runner page. If the build agents do not include PhantomJS, you can commit it to your repository along with your sources (this is what we do).
The result will look like this:
Test details:
The above is from a Tasks sample ASP.NET MVC project with this setup. It can be run in TeamCity using a Visual Studio (sln) build step. It will also run the tests within Visual Studio, as a pre-build step.
Related
I'm tracking the files of my golang app in a local TFS server integrated with git. I want to define build, test, and deploy steps but I can't find any tool for that.
How can I define a build and test step for the project that shows the test results in the Team's web site? thank you.
You can use the vNext build system in TFS2017 and add Command Line task in the build definition to run the build and test just like what you do on local machine:
And then add a "Publish Test Result" task to publish the test result to TFS so that you can check the test result from the TFS Website. A limitation is that "Publish Test Result" task only support four Test Result Format for now: JUnit, NUnit, VSTest and XUnit.
I have the following project in my Visual Studio 2015 solution. I want to execute jasmine tests as part of our TFS CI build. I can run my tests successfully when I open the SpecRunner.html file although I'm failing to get them to run as part of the TFS build. I've included a screen shot of my TFS build step definition. The build is successful but the tests are not executed.
Please advise, any help greatly appreciated.
Many thanks,
Project and file locations
TFS build step
First make sure your environment on the build sever is set correct. You could manually run the test on the build server.
To use a NuGet package for the Chutzpah test runner , then you can avoid having to manually unpack the VSIX and get it into source control to deploy it to the build host.
About the detail step and build definition you could take a look at this tutorial: nUnit and Jasmine.JS unit tests in TFS/VSO vNext build
I have a C# project in Xamarin for which I've written a few NUnit unit tests. To alert me to regressions as soon as possible I'd like to have Xamarin run my unit tests after every build. I'm not using CI or a build server, everything is local to my dev machine. Is there a way to modify the build task to run my tests after each compilation?
You can write a simple build script in which you invoke nunit-console.exe after your msbuild of your respective Xamarin projects.
Otherwise, I would personally recommend using Cake Build as it's fairly simple to get up and running and provides NUnit runners:
https://github.com/cake-build/cake (http://cakebuild.net/)
https://github.com/Redth/Cake.Xamarin (Xamarin Addin)
Both of these solutions should work fine locally.
Taking elements from #JonDouglas' suggestion I ended up finding the Custom Commands section and making an After Build with nunit-console ${TargetFile}. It's in the Options dialog here:
I've setup my build as below using the build definition. I'm using XUnit and locally my tests are discovered and run. I've tested the glob **\*spec*.dll and it finds all my test dlls and the build log shows that those dlls are in fact built.
However in the build log I get
Run VS Test Runner
No test found. Make sure that installed test
discoverers & executors, platform & framework
version settings are appropriate and try again.
Which seems to suggest it is trying to use the MSTest test runner instead of the XUnit test runner. How do I tell the build for visual studio online to use the XUnit test runner and discoverer?
This might be out of date now, but this is how I have it setup and working - downvote and let me know if it's wrong and I'll delete this. I got it from a blog post/MSDN page, but I can't locate it any more.
First you need to create a TFVC Team Project (doesn't matter if you don't use it again).
Into $/MyTFVC/BuildProcessTemplate/CustomActivities/
Checking the following files from xunit.net:
Now in VS, click the BUILD, Manage Build Controllers... option. Select the "Hosted Build Controller (Hosted)" and click "Properties...".
Enter the path where you checked in the DLL's into the "Version control path to custom assemblies" field:
You should be good to go.
Currently I have a setup of build controllers. I want to run automation test scripts referring to some dll. I tried giving the set-up in Process tab of build definition under automated tests. But nothing happens. Please guide what things are necessary for running automated tests.
This is a good guide to setting up automated unit test in TFS Builds: http://geekswithblogs.net/jakob/archive/2009/06/03/tfs-team-build-2010-running-unit-tests.aspx