Tag Archives: unit testing

Building and testing .NET application in command line

Setup: Windows – .NET 4.5, Linux – Mono 3, Mint 17 (based on Ubuntu 14). I need to build and test .NET application from command line and on CI server.
Sample solution can be downloaded from here https://github.com/mchudinov/BuildingTesting. Solution is compatible with MonoDevelop 5, Xamarin Studio 5 and Visual Studio 2012,2013,2015.

building_bricks

1. Building in command line

There are two standard command line building tools for .NET: MSBuild on Windows and xbuild on Linux/Mono. xbuild build files are compatible (with some exceptions) with MSBuild files.

We need at least 4 simple steps (targets as they called in MSBuild terminology) to build a .NET solution:

  • Clean
  • Restore NuGet packages
  • Build binaries
  • Run unit tests

Continue reading

How to mock different methods of the same class and how to mock one method with different arguments

I want to mock different methods of the same class and mock one method with different argument values. Using standard PHPUnit.

Mocks in PHPUnit are being created using getMock() method. It belongs to PHPUnit_Framework_TestCase class, that is described in .../PEAR/PHPUnit/Framework/TestCase.php file. Continue reading

How to create mock for a method with reference parameters

While testing PHP we need sometimes to create a mock for a method with reference parameters. I use returnCallback() from PHPUnit framework to to this. returnCallback() will call a function that imitates functionality of the original method. The original method can be either public or protected.
Continue reading