Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Xamarin.Android.Build.Tasks] First Pass at adding Unit tests for the MSBuild Tasks #26

Merged
merged 1 commit into from
May 12, 2016

Commits on May 12, 2016

  1. [Xamarin.Android.Build.Tasks] First Pass at adding Unit tests for the…

    … MSBuild Tasks
    
    This commit adds basic support for the MSBuild Unit Tests. The goal
    of these tests is to ensure that the build of an android applicaition
    works consistently on all the supported platforms.
    
    The basic layout of a Unit test is as follows
    
    	[Test]
    	public void BuildReleaseApplication ()
    	{
    		var proj = new XamarinAndroidApplicationProject () {
    			IsRelease = true,
    		};
    		using (var b = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) {
    			Assert.IsTrue (b.Build (proj), "Build should have succeeded.");
    		}
    	}
    
    It is a standard Unit test. First we create a XamarinAndroidApplicatonProject
    and set its properties. You can use the proj to add new source files,
    references, assets, resources and nuget packages. By default you will get
    a standard "HelloWorld" android application.
    Once you have the project you will need to create either a Apk or Dll builder
    via the helper methods
    
    	CreateApkBuilder
    	CreateDllBuilder
    
    CreateApkBuilder will create an apk and by default will execute the
    `SignAndroidPackage` build target. the CreateDllBuilder will produce
    a dll. The source files are created in a temp directory relative to
    the build output of the unit tests. By default this is
    
    	src/Xamarin.Android.Build.Tasks/UnitTests/Xamarin.Android.Build.Tests/bin/$(Configuraiton)/temp
    
    Once you have a builder you can then call Build passing in the project. There are
    also methods available for Clean and Save. Running any of these will cause
    the Unit test to shell out to xbuild/msbuild and attempt to build the project.
    Test results are written to a build.log file.
    If a unit test passes then the test directory is removed. If a test fails
    the directory and the build.log will be left in place for investigation.
    dellis1972 committed May 12, 2016
    Configuration menu
    Copy the full SHA
    4efc24a View commit details
    Browse the repository at this point in the history