Showing posts with label Continous Integration. Show all posts
Showing posts with label Continous Integration. Show all posts

Friday, June 07, 2013

Team Foundation 2012: Run xUnit unit tests

Currently I am using https://tfs.visualstudio.com/ and writing my unit tests with xUnit. To enable this follow the steps outlined on MSDN.


You can find the binaries in the packages folder in your solution directory

Monday, June 20, 2011

Something on Continuous Integration

In the past I have been experiencing some weird practices concerning CI. In the following article I will outline some do's and don'ts when implementing continuous integration.

First and foremost it is ok to break a build that is why the thing is there you know. Comparing the number of broken builds against the ones that don't break is not a good measure of quality instead measure the time to fix the build.

Do Integrate static code analysis in your build like FxCop, Ndepend and Simian. Giving you early feedback on your code quality. If the tools give you warnings solve them as well. If you keep up on regular basis this will keep your code base clean.

Do Integrate your Unit tests to run every build. Again providing early feedback on integration issues.

Do provide visual feedback (Andon) that give people an immediate feedback when a build fails.

Don't force developers to do a get latest, run all their unit tests and then check in. This is a waste of time. But when a build fails fix it!

Don't seek who broke the build. Something that is very common is that people are very eager to investigate who broke the build and pointing fingers. Instead look what broke the build try to fix it, this will enhance collective code ownership.

Don't check in, close your laptop and sprint out of the office. This practice kills team morale.

Monday, April 14, 2008

Continous Integration and the Database

Spend some few days setting up a continous integration for a database project. Found some stuff on the internet but they got it all wrong :)

I am using Team Foundation Server 2008.

The only thing you need to do is modify the TFSBuild.proj

Modify the following sections. This enabled the automatic generation of a sql script that will be copied in the Drop Folder.
Find the SoltionToBuild tag and add the properties as shown below:




<SolutionToBuild Include="$(BuildProjectFolderPath)/../../CIDB/CIDB.sln">
<Targets></Targets>
<Properties>DefaultDataPath=C:\BuildDrop\;TargetDataBase=TestDb</Properties>
</SolutionToBuild>

Add the default configuration to the ConfigurationToBuild ItemGroup as shown below (make sure to match it to your settings in the Configuration Manager)
<ItemGroup>
<!-- CONFIGURATIONS
The list of configurations to build. To add/delete configurations, edit this value. For example,
to add a new configuration, add the following lines:

<ConfigurationToBuild Include="Debugx86">
<FlavorToBuild>Debug</FlavorToBuild>
<PlatformToBuild>x86</PlatformToBuild>
</ConfigurationToBuild>

The Include attribute value should be unique for each ConfigurationToBuild node.
-->
<ConfigurationToBuild Include="ReleaseAny CPU">
<FlavorToBuild>Release</FlavorToBuild>
<PlatformToBuild>Any CPU</PlatformToBuild>
</ConfigurationToBuild>

<!--Include the configuration to build this generates a .sql file in the drop folder-->
<ConfigurationToBuild Include="DefaultAnyCPU">
<FlavorToBuild>Default</FlavorToBuild>
<PlatformToBuild>Any CPU</PlatformToBuild>
</ConfigurationToBuild>
</ItemGroup>

Next add the following section to the end of the TFSBuild.proj file. the %3B is the escape character for ';' in MSBuild




<PropertyGroup>


<TargetConnection>Data Source=.%3BIntegrated Security=True%3BPooling=False</TargetConnection>
<DefaultDataPath>C:\BuildDrop\</DefaultDataPath>
<TargetDataBase>DevDb</TargetDataBase>
</PropertyGroup>


<Target Name="AfterDropBuild">
<MSBuild Projects="$(SolutionRoot)\CIDB\CIDB\CIDB.dbproj"
Properties="Configuration=Default;
OutDir=$(SolutionRoot)\..\binaries\Default\;
AlwaysCreateNewDatabase=false;
TargetConnectionString=$(TargetConnection);
DefaultDataPath=$(DefaultDataPath);
TargetDataBase=$(TargetDataBase)"

Targets="ReBuild;Deploy" /> <!—Need to specify the Rebuild target otherwise fails -->
</Target>

Update:

If you modify your source folder setting in the workspace - defaults to $(SourceDir)- make sure that you override your SolutionRoot property

by adding the following

...

</ProjectExtensions>
<PropertyGroup>

<SolutionRoot>C:\Workspace_Build02 </SolutionRoot>

....




Thats all there is to it :)



Coming up automatically generate an upgrade script to deploy to production systems... I installed the Database Team Edition on the build agent but I am not quite sure if its necessary I will investigate this... I dont know if its default part of ms build