Archive for the ‘How-To's’ Category

.NET Code Coverage in Two Clicks

Friday, February 19th, 2010

If you have ever dealt with .NET code coverage for NUnit tests, you surely know that it is quite a tricky thing to configure: you need to read docs to properly set up launching a command line coverage tool in your build script; read more docs and configure how reports should be gathered; then read docs again and specify all the needed arguments to be passed… well, not a task anyone would like to deal with.

Now imagine that you can forget all that tangled routine and spend more time doing whatever you like. That’s because starting with TeamCity 5.0 configuring coverage execution with NUnit becomes easy as pie.

All you need to do is to select the preferred coverage tool when creating or editing Build ConfigurationNCover and PartCover are at your disposal; and specify its parameters. That’s it!

Just a few clicks to make TeamCity automatically add necessary arguments to NUnit tests, and ensure you’ll be able to view the results in the TeamCity. Enjoy!

Code Coverage Results

Code Coverage Results

Code Coverage Summary

Code Coverage Summary

Coverage Graph

Coverage Graph











Sincerely,
JetBrains TeamCity team.

Technorati tags: , , , , , , ,

Using TeamCity NUnit Launcher

Wednesday, September 24th, 2008

After not so short break we are back with the next post of our .NET mini-series, and today we are going to tell you about TeamCity NUnit Launcher — a bundled NUnit test runner. In most cases, if you need to use NUnit, all you have to do is just to run it with this Launcher.

As we said in the previous post, to provide tests state tracking and on-the-fly reporting, TeamCity contains several NUnit builds (different NUnit versions) and provides NUnit Launcher to use particular NUnit build for your tests.

To start the NUnit Launcher from any TeamCity build runner, use either the teamcity.dotnet.nunitlauncher NAnt property, or the environment variable of the same name, or the teamcity_dotnet_nunitlauncher MSBuild property. These properties should have the following mandatory parameters:

  • .NET Framework version (both 1.1 and 2.0 versions are supported),
  • The platform to run tests (x86, x64, and MSIL),
  • The test framework version to use. TeamCity supports the following NUnit versions: 2.2.10, 2.4.1, 2.4.6, 2.4.7, 2.4.8, and 2.5.0 (Alpha 3)
  • List of assemblies to test

In addition to the above-mentioned parameters, you can also specify filters by tests category and NUnit addins (for NUnit 2.4 and higher). Filters by tests category allow you to control a set of tests to run, if you use tests grouping by category in your project.

You can find the detailed description of TC NUnit Launcher syntax at TeamCity reference. Here, in this post, we will just illustrate it with the example below.
(more…)

Unfolding TeamCity Addin for NUnit Secrets

Monday, July 28th, 2008

In today’s episode of the NUnit mini-series we’d like to share some information on using TeamCity Addin for NUnit.

As we wrote in our previous post, to provide tests state tracking and on-the-fly reporting, TeamCity bundles NUnit and includes its own NUnit runners. These embedded runners suit most cases perfectly well but there can be situations when you:

  • prefer to use particular NUnit instance (not TeamCity’s bundled) for your particular build configuration
  • want to pass NUnit project file (.nunit)

For cases like these you can use a recently implemented TeamCity Addin for NUnit available in TeamCity 4.0 EAP; the Addin supports the following versions of NUnit: 2.4.6, 2.4.7, 2.4.8 and 2.5.0 Alpha3.

How does it work?
TeamCity Addin for NUnit is embedded in the system by default and contains .dll and .pdb files for each supported version of NUnit. For every build, the main part of a path to the TeamCity Addin is set to the build property and the environment variable of the same name:

  • teamcity.dotnet.nunitaddin for NAnt
  • teamcity_dotnet_nunitaddin for MSBuild

To enable on-the-fly tests reporting, all you have to do is to add a task in your build for copying an appropriate Addin’s files to your NUnit’s addins directory. Type your NUnit version at the end of the TeamCity Addin path using the following syntax:

  • For NAnt: ${teamcity.dotnet.nunitaddin}-<NUnit version>.dll
  • For MSBuild: $(teamcity_dotnet_nunitaddin)-<NUnit version>.dll

In the above filenames, the <NUnit version> parameter can possess the following values: 2.4.6, 2.4.7, 2.4.8, and 2.5.0.

Please note that we recommend to copy TeamCity Addin for NUnit files every time you run the particular build.

The following example for MSBuild shows how to use NUnit console runner with TeamCity Addin for NUnit 2.4.7:


<PropertyGroup>
   <NUnit>Path_to_NUnit_console</NUnit>
   <NUnitAddinsDir>Path_to_NUnit_Addins _Dir</NUnitAddinsDir>
</PropertyGroup>

<ItemGroup>
   <NUnitAddinFiles Include="$(teamcity_dotnet_nunitaddin)-2.4.7.*" />
</ItemGroup>

<Target Name="RunTests">
   <Copy SourceFiles="@(NUnitAddinFiles)" DestinationFolder="$(NUnitAddinsDir)" />
   <Exec Command="$(NUnit) $(NUnitFileName)" />
</Target>

 

Well, it’s again a time for a break. See you soon!

Technorati tags: , , , , , , , , ,

Managing TeamCity Database

Tuesday, June 3rd, 2008

Here, at JetBrains, we use TeamCity to build all our projects - commercial, open-source, and internal solutions. This is why we understand the value and importance of information that will be kept “inside” TeamCity server as well as the burden of setup, adoption, and maintenance of “yet another server” for your company.This is why we support four major industry-wide databases:

  • MySQL (5.0.40+)
  • PostreSQL (8+)
  • Oracle (10+)
  • Microsoft SQL 2005

to back end your TeamCity server, so you can reuse your existing IT infrastructure in the most efficient way.Â

To ease the evaluation process, TeamCity comes with a built-in pure Java database (HSQLDB) that works out of the box under any environment without any additional configuration. When you evaluate TeamCity to see whether it suits your needs and which benefits it brings, it collects information on the build results and preserves it in this simple built-in database. But because of its simplicity, the database does not scale well and is not targeted on a real production.

Once you decide to handle the software building process to TeamCity and use it for production purposes, you need to switch to one of the supported databases most suitable for your environment and infrastructure. Please note that after initial setup the external database does not require any kind of special maintenance - TeamCity server does everything automatically using the database you have selected, and you control performance, scalability, and safety.

The database switching process is rather simple and straightforward:

  1. Stop TeamCity server.
  2. Back up the TeamCity data directory.
  3. Follow an extensive explanation of this procedure in the Setting up an External Database and Migrating to an External Database sections of our online reference.

We strive to make both adoption and production usage as easy as possible, and if you have any questions, comments or suggestions, please don’t hesitate to drop us a line - either here or at teamcity-feedback at jetbrains dot com.

Technorati tags: , , , , , , , , , , , , , , ,

Build triggering: already existing and more upcoming in TeamCity 3.1

Thursday, January 31st, 2008

A flexible system of different build triggers in TeamCity allows to start the builds when it’s really necessary rather then use your company’s hardware resources at their most - running multiple builds at the same time and making you wait for the feedback on changes’ integration results.

Let’s now take a look at how TeamCity can help to “tame” builds clutter.

The most common case of firing a new build - changes committed to the version control system - can be altered by specifying a “quiet period” - time to pass with no changes in the build configuration VCS roots before TC starts a new build. In addition, you can use wildcards and operators to exclude parts of the VCS roots and ignore commits of particular users.

It’s quite common for many companies to create new builds periodically. In this case TeamCity can still limit the builds number if there are no changes pending to be built.

In TeamCity 3.1 which we plan to release soon, we’ve implemented more flexible build triggering options using Cron Expressions for more precise schedule tuning:

cronexpressiontrigger.jpg

You can also specify to start a new build when a successful build of a dependent build configuration appears or when the previous build has failed.

In-depth build triggering options are, as usual, explained in online reference.

Technorati tags: , ,, , , , , , ,

Labeling the VCS roots of finished builds

Monday, January 7th, 2008

TeamCity has two ways to label the build’s sources: automatic and manual one. So, let’s start with adding labels into the VCS for the build’s sources.

TeamCity can optionally add a label into the version control system for the sources used for a particular build. This can be useful, for example, when you need to have all the build’s sources to reproduce it. Opt to apply the VCS label for all builds or only for successful ones.

TeamCity supports VCS labeling for VCS roots managed by the following configuration management systems:

  • ClearCase,
  • CVS,
  • Perforce,
  • StarTeam,
  • Subversion.

The labeling takes place after the build’s finish and doesn’t affect the build status.

To enable the builds labeling:

  1. Navigate to Administration section, select the already existing project in the Projects list or start creating a new one.
  2. Go the step 2 “Version control settings” definition, select the labeling mode and save your changes.
  3. vcslabelingmode.png

Besides automatic build labeling, you can label sources used for a build manually. Navigate to the Build Results page, Changes tab and click Label this build sources link.
changestab.png

See more in TeamCity online reference.

Technorati tags: , , , , , , , , , , , ,

Analyzing thread dumps

Wednesday, December 19th, 2007

A useful feature helping to troubleshoot hangs and deadlocks in Java and .NET threads, is now available in TeamCity 3.0. You have a possibility to view stacktraces of all threads of all build’s processes on the build agent.

Taking a look at the thread dump can be an effective approach when detecting the leaves threads. The threads can be leaved as side effects of the system function or as a gap in some unit test.

TeamCity supports thread dumps for Microsoft .NET Framework 2.0 processes and Java 1.3 on Windows OS. On all other platforms it supports only Java from 1.5 and later.

To take a thread dump, find a running build on the Projects page, click it to navigate to the build results page and then click View thread dump link:

viewthreaddump.png

TeamCity tries to fetch the processes which take place at the moment and shows a window with a tree-like view of processes as well as their command line and stacktraces. Click the process name to investigate the the problem deeper.
Here is an example of how TeamCity represents both Java and .NET processes taking place when running a build.
Java process thread:

.NET process thread:

Note: If a build is running under Windows OS and Java 1.6, it uses a jstack utility to obtain a thread dump. This utility is also used to obtain thread dumps for all other platforms.

Have an untroubled and uninterrupted building!

Technorati tags: , , , , , ,, , ,

Discovering “hanging” builds with TeamCity

Friday, December 14th, 2007

In TeamCity 3.0 we implemented one small but useful feature assisting you with builds’ state troubleshooting: discovering builds which are probably “hanging” at the moment and displaying this information on the Projects and Build Configuration’s homepage:

Hanging Builds

Of course you don’t always watch and have to watch the project’s health at the projects’ dashboard or the build configuration’ homepage and prefer to stay tuned to your workflow but be informed of hanging builds so your precious time is not wasted and the feedback loop stays reasonable. Nothing more simpler, just customize the notification rule:

  1. Navigate to My Settings and Tools | Watched builds and Notifications area.
  2. Click the Edit button near the desired notification means (e-mail, Windows Tray Notifier, e-mail, Jabber or IDE notifier).
  3. If you already have some notification rules, click the edit link and select The build is probably hanging option. Otherwise create a new notification rule and enable this option.
  4. Editing notification rules

  5. Click Save.

Now you can stay tuned to the development or builds management process but you won’t miss the hanging builds situation which may be even dangerous if the changes need to be incorporated quickly and build must be delivered within a very tough timeframe.

Technorati tags: , ,, , , , , , , , , ,

Personilized RSS Feeds for Builds Results

Tuesday, November 27th, 2007

In the latest TeamCity 3.0 EAP releases we added one more feature helping to keep you up with the status of builds of the certain build configurations – getting reports on their status via syndication feeds.

You can specify the content of your personalized feed selecting from a wide range of settings and subscribe to it, for example, using some external application. Receive new feed entries for:

  • all new builds or only successful or failed ones
  • builds triggered by changes of all users or a particular user in your company, or only your changes

To create a custom RSS feed and subscribe to it:

  1. Navigate to My Settings and Tools page, TeamCity Add-ons area, Syndication Feed and click Customize.
  2. On the new page that opens specify a number of options:
    • select Build Configurations (multiple selection is available)
    • determine the Feed Entries you want to be included in the reports (events such as builds, changes of particular users or both, triggering the syndication feed generation)
    • enter the authentication settings if required
  3. Copy and paste the resulting URL into your feed reader or click the Subscribe link and then select the desired application for reading the feed.

The resulting feed will be updated as soon as the new build matching the selected requirements completes.

The feed entries contain the summary of results of builds of the certain build configurations and navigatable links to the build changes and the build log:
feedsinomea.png

Besides feed URL generator, it is possible to obtain the information about the finished builds from the home page of a build configuration.

Technorati tags: ,, , , , , , , , , , , ,

Specifying the Artifact Dependencies in TeamCity

Friday, October 26th, 2007

Since version 2.0 TeamCity allows to specify the dependencies between the results of the builds of the build configurations, i.e. artifact dependencies and provides dependent builds triggering.

When creating new builds, it’s possible to use the artifacts of:

  • last pinned build,
  • successful build,
  • last finished build (can be useful when integrating with changes third-party libraries)
  • build with a particular number

In the artifacts paths you can use regular expressions or file patters. One or several artifacts paths can be specified.
It’s also possible to specify the destination directory where the artifacts are downloaded when the build is started and configure whether to clean the catalogue before creating builds and downloading artifacts to avoid artifacts clutter.

The artifact dependencies are set up when you create or edit the build configuration:artifactdependency.png

Since TeamCity itself acts like an Ivy repository it allows you to download the artifacts using Ivy tasks or Ivy tool from the command line. The dependencies are specified in the ivy.xml configuration file, you can put the file in your CMS repository and safely test changes in this file when running personal builds. You need to download the Ivy Dependency manager from http://ant.apache.org/ivy/ and follow the steps described in TeamCity online reference.

In the latest TeamCity 3.0 EAP versions we provide a possibility to view the info on the build artifacts were used to create the build on the Build Results page:

artifactdependencies.png

Technorati tags: ,, , , , , , , , ,