Skip to content

Commit ff59a53

Browse files
committed
Merge branch 'release/0.12.0'
* release/0.12.0: (#23) Add support for integration tests
2 parents 43ebf40 + 8fa85ca commit ff59a53

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

Chocolatey.Cake.Recipe/Content/parameters.cake

+26-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public static class BuildParameters
1818
public static string PreReleaseLabelFilePath { get; private set; }
1919
public static string Target { get; private set; }
2020
public static string BuildCounter { get; private set; }
21+
public static string TestExecutionType { get; private set; }
2122
public static string Configuration { get; private set; }
2223
public static string DeploymentEnvironment { get; private set;}
2324
public static Cake.Core.Configuration.ICakeConfiguration CakeConfiguration { get; private set; }
@@ -44,7 +45,8 @@ public static class BuildParameters
4445
public static DirectoryPath SolutionDirectoryPath { get; private set; }
4546
public static DirectoryPath TestDirectoryPath { get; private set; }
4647
public static FilePath IntegrationTestScriptPath { get; private set; }
47-
public static string TestFilePattern { get; private set; }
48+
public static string TestAssemblyFilePattern { get; private set; }
49+
public static string TestAssemblyProjectPattern { get; private set; }
4850
public static string Title { get; private set; }
4951
public static string ResharperSettingsFileName { get; private set; }
5052
public static string RepositoryOwner { get; private set; }
@@ -160,6 +162,7 @@ public static class BuildParameters
160162
context.Information("RepositoryName: {0}", RepositoryName);
161163
context.Information("NugetConfig: {0} ({1})", NugetConfig, context.FileExists(NugetConfig));
162164
context.Information("Build Counter: {0}", BuildCounter);
165+
context.Information("Test Execution Type: {0}", TestExecutionType);
163166
context.Information("RestorePackagesDirectory: {0}", RestorePackagesDirectory);
164167
context.Information("ProductName: {0}", ProductName);
165168
context.Information("ProductDescription: {0}", ProductDescription);
@@ -174,6 +177,8 @@ public static class BuildParameters
174177
context.Information("StrongNameDependentAssembliesInputPath: {0}", StrongNameDependentAssembliesInputPath);
175178
context.Information("ShouldStrongNameChocolateyDependenciesWithCurrentPublicKeyToken: {0}", ShouldStrongNameChocolateyDependenciesWithCurrentPublicKeyToken);
176179
context.Information("AssemblyNamesRegexPattern: {0}", AssemblyNamesRegexPattern);
180+
context.Information("TestAssemblyFilePattern: {0}", TestAssemblyFilePattern);
181+
context.Information("TestAssemblyProjectPattern: {0}", TestAssemblyProjectPattern);
177182
context.Information("UseChocolateyGuiStrongNameKey: {0}", UseChocolateyGuiStrongNameKey);
178183
context.Information("AllowedAssemblyName: {0}", string.Join(", ", AllowedAssemblyNames));
179184
context.Information("TransifexEnabled: {0}", TransifexEnabled);
@@ -206,7 +211,8 @@ public static class BuildParameters
206211
DirectoryPath solutionDirectoryPath = null,
207212
DirectoryPath rootDirectoryPath = null,
208213
DirectoryPath testDirectoryPath = null,
209-
string testFilePattern = null,
214+
string testAssemblyFilePattern = null,
215+
string testAssemblyProjectPattern = null,
210216
string integrationTestScriptPath = null,
211217
string resharperSettingsFileName = null,
212218
string repositoryOwner = null,
@@ -293,7 +299,6 @@ public static class BuildParameters
293299
SolutionDirectoryPath = solutionDirectoryPath ?? SourceDirectoryPath.Combine(Title);
294300
RootDirectoryPath = rootDirectoryPath ?? context.MakeAbsolute(context.Environment.WorkingDirectory);
295301
TestDirectoryPath = testDirectoryPath ?? sourceDirectoryPath;
296-
TestFilePattern = testFilePattern;
297302
IntegrationTestScriptPath = integrationTestScriptPath ?? context.MakeAbsolute((FilePath)"test.cake");
298303
ResharperSettingsFileName = resharperSettingsFileName ?? string.Format("{0}.sln.DotSettings", Title);
299304
RepositoryOwner = repositoryOwner ?? string.Empty;
@@ -386,6 +391,24 @@ public static class BuildParameters
386391

387392
Target = context.Argument("target", "Default");
388393
BuildCounter = context.Argument("buildCounter", BuildProvider.Build.Number);
394+
TestExecutionType = context.Argument("testExecutionType", "unit");
395+
396+
if (TestExecutionType == "unit")
397+
{
398+
TestAssemblyFilePattern = testAssemblyFilePattern ?? "/**/*[tT]ests.dll";
399+
TestAssemblyProjectPattern = testAssemblyProjectPattern ?? "/**/*[tT]ests.csproj";
400+
}
401+
else if (TestExecutionType == "integration")
402+
{
403+
TestAssemblyFilePattern = testAssemblyFilePattern ?? "/**/*[tT]ests.[iI]ntegration.dll";
404+
TestAssemblyProjectPattern = testAssemblyProjectPattern ?? "/**/*[tT]ests.[iI]ntegration.csproj";
405+
}
406+
else if (TestExecutionType == "all")
407+
{
408+
TestAssemblyFilePattern = testAssemblyFilePattern ?? "/**/*{[tT]ests|[tT]ests.[iI]ntegration}.dll";
409+
TestAssemblyProjectPattern = testAssemblyProjectPattern ?? "/**/*{[tT]ests|[tT]ests.[iI]ntegration}.csproj";
410+
}
411+
389412
Configuration = context.Argument("configuration", "Release");
390413
DeploymentEnvironment = context.Argument("environment", "Release");
391414
ForceContinuousIntegration = context.Argument("forceContinuousIntegration", false);

Chocolatey.Cake.Recipe/Content/testing.cake

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ BuildParameters.Tasks.TestNUnitTask = Task("Test-NUnit")
2121
Information("Running OpenCover and NUnit...");
2222

2323
OpenCover(tool => {
24-
tool.NUnit3(GetFiles(BuildParameters.Paths.Directories.PublishedNUnitTests + (BuildParameters.TestFilePattern ?? "/**/*[tT]ests.dll")), new NUnit3Settings {
24+
tool.NUnit3(GetFiles(BuildParameters.Paths.Directories.PublishedNUnitTests + BuildParameters.TestAssemblyFilePattern), new NUnit3Settings {
2525
Work = BuildParameters.Paths.Directories.NUnitTestResults
2626
});
2727
},
@@ -40,7 +40,7 @@ BuildParameters.Tasks.TestNUnitTask = Task("Test-NUnit")
4040
Information("Running NUnit...");
4141

4242
// OpenCover doesn't work on anything non-windows, so let's just run NUnit by itself
43-
NUnit3(GetFiles(BuildParameters.Paths.Directories.PublishedNUnitTests + (BuildParameters.TestFilePattern ?? "/**/*[tT]ests.dll")), new NUnit3Settings {
43+
NUnit3(GetFiles(BuildParameters.Paths.Directories.PublishedNUnitTests + BuildParameters.TestAssemblyFilePattern), new NUnit3Settings {
4444
Work = BuildParameters.Paths.Directories.NUnitTestResults
4545
});
4646
}
@@ -58,7 +58,7 @@ BuildParameters.Tasks.TestxUnitTask = Task("Test-xUnit")
5858
Information("Running OpenCover and xUnit...");
5959

6060
OpenCover(tool => {
61-
tool.XUnit2(GetFiles(BuildParameters.Paths.Directories.PublishedxUnitTests + (BuildParameters.TestFilePattern ?? "/**/*[tT]ests.dll")), new XUnit2Settings {
61+
tool.XUnit2(GetFiles(BuildParameters.Paths.Directories.PublishedxUnitTests + BuildParameters.TestAssemblyFilePattern), new XUnit2Settings {
6262
OutputDirectory = BuildParameters.Paths.Directories.xUnitTestResults,
6363
XmlReport = true,
6464
NoAppDomain = true
@@ -79,7 +79,7 @@ BuildParameters.Tasks.TestxUnitTask = Task("Test-xUnit")
7979
Information("Running xUnit...");
8080

8181
// OpenCover doesn't work on anything non-windows, so let's just run xUnit by itself
82-
XUnit2(GetFiles(BuildParameters.Paths.Directories.PublishedxUnitTests + (BuildParameters.TestFilePattern ?? "/**/*[tT]ests.dll")), new XUnit2Settings {
82+
XUnit2(GetFiles(BuildParameters.Paths.Directories.PublishedxUnitTests + BuildParameters.TestAssemblyFilePattern), new XUnit2Settings {
8383
OutputDirectory = BuildParameters.Paths.Directories.xUnitTestResults,
8484
XmlReport = true,
8585
NoAppDomain = true
@@ -107,7 +107,7 @@ BuildParameters.Tasks.DotNetCoreTestTask = Task("DotNetCoreTest")
107107
msBuildSettings.WithProperty("FrameworkPathOverride", frameworkPathOverride);
108108
}
109109

110-
var projects = GetFiles(BuildParameters.TestDirectoryPath + (BuildParameters.TestFilePattern ?? "/**/*Tests.csproj"));
110+
var projects = GetFiles(BuildParameters.TestDirectoryPath + BuildParameters.TestAssemblyProjectPattern);
111111
// We create the coverlet settings here so we don't have to create the filters several times
112112
var coverletSettings = new CoverletSettings
113113
{

0 commit comments

Comments
 (0)