Skip to content

Instantly share code, notes, and snippets.

@iwillspeak
Last active Aug 19, 2021
Embed
What would you like to do?
Example Cake Script for Tyrannoport
bin/
obj/
TestReports/
tools/
/.config/

This repo demonstrates a simple build.cake that calls the Tyrannoport tool to generate a test report.

Once cloned you will need to install cake: $ dotnet new tool-manifest && dotnet tool install cake.tool

You should then be able to run the cake targets:

dotnet cake
#tool "dotnet:?package=Tyrannoport&version=0.3.14"
#addin "nuget:?package=Cake.Tyrannoport&version=0.3.14"
var target = Argument("target", "Test");
var configuration = Argument("configuration", "Release");
var trxPath = MakeAbsolute(Directory("TestReports") + File($"Trx-{Guid.NewGuid()}.trx"));
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
Task("Test")
.Does(() =>
{
DotNetCoreTest("./TyrannoportCakeExample.csproj", new DotNetCoreTestSettings
{
Configuration = configuration,
Loggers = {
$"trx;LogFileName={trxPath.FullPath}"
}
});
})
.Finally(() =>
{
Tyrannoport(trxPath);
});
//////////////////////////////////////////////////////////////////////
// EXECUTION
//////////////////////////////////////////////////////////////////////
RunTarget(target);
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="github" value="https://nuget.pkg.github.com/iwillspeak/index.json" />
<add key="NuGetOrg" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="1.3.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>
using System;
using Xunit;
namespace TyrannoportCakeExample
{
public class UnitTest1
{
[Fact]
public void Test1()
{
}
[Fact]
public void Fail()
{
Assert.Equal("something", "somewhat different");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment