Skip to content

Commit 213f10b

Browse files
author
Jake Ginnivan
committed
Improved acceptance tests heaps
1 parent 4cdb915 commit 213f10b

26 files changed

+256
-458
lines changed

AcceptanceTests/AcceptanceTests.csproj

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,16 @@
4040
<Reference Include="LibGit2Sharp">
4141
<HintPath>..\packages\LibGit2Sharp.0.16.0.0\lib\net35\LibGit2Sharp.dll</HintPath>
4242
</Reference>
43+
<Reference Include="Shouldly">
44+
<HintPath>..\packages\Shouldly.2.1.1\lib\net40\Shouldly.dll</HintPath>
45+
</Reference>
4346
<Reference Include="System" />
4447
<Reference Include="System.Core" />
4548
<Reference Include="System.Web.Extensions" />
4649
<Reference Include="System.Xml.Linq" />
4750
<Reference Include="System.Data.DataSetExtensions" />
4851
<Reference Include="System.Data" />
4952
<Reference Include="System.Xml" />
50-
<Reference Include="TestStack.BDDfy, Version=3.19.1.0, Culture=neutral, PublicKeyToken=a357057d05a879bd, processorArchitecture=MSIL">
51-
<SpecificVersion>False</SpecificVersion>
52-
<HintPath>..\packages\TestStack.BDDfy.3.19.1\lib\NET40\TestStack.BDDfy.dll</HintPath>
53-
</Reference>
5453
<Reference Include="xunit">
5554
<HintPath>..\packages\xunit.1.9.2\lib\net20\xunit.dll</HintPath>
5655
</Reference>
@@ -60,15 +59,16 @@
6059
</ItemGroup>
6160
<ItemGroup>
6261
<Compile Include="ExecArgSpecification.cs" />
62+
<Compile Include="NormaliseGitDirectoryInTeamCity.cs" />
63+
<Compile Include="RepositoryFixture.cs" />
6364
<Compile Include="Helpers\ExecutionResults.cs" />
6465
<Compile Include="Helpers\GitHelper.cs" />
6566
<Compile Include="Helpers\GitVersionHelper.cs" />
6667
<Compile Include="Helpers\IPostTestDirectoryRemover.cs" />
6768
<Compile Include="Helpers\PathHelper.cs" />
6869
<Compile Include="Helpers\ProcessHelper.cs" />
6970
<Compile Include="Helpers\Scrubbers.cs" />
70-
<Compile Include="GitHubFlow\NoTagsInRepositorySpecification.cs" />
71-
<Compile Include="GitHubFlow\NoTagsInRepositoryWithNextVersionTxtSpecification.cs" />
71+
<Compile Include="GitHubFlow\MasterTests.cs" />
7272
<Compile Include="ProjArgSpecification.cs" />
7373
<Compile Include="Properties\ApprovalTestsConfig.cs" />
7474
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -77,11 +77,6 @@
7777
<DesignTime>True</DesignTime>
7878
<DependentUpon>Resources.resx</DependentUpon>
7979
</Compile>
80-
<Compile Include="GitHubFlow\PullRequestsFixture.cs" />
81-
<Compile Include="GitHubFlow\RepositoryFixture.cs" />
82-
<Compile Include="GitHubFlow\TagFollowedByCommitsWithApplicableNextVersionTxtSpecification.cs" />
83-
<Compile Include="GitHubFlow\TagFollowedByCommitsWithNoNextVersionTxtSpecification.cs" />
84-
<Compile Include="GitHubFlow\TagFollowedByCommitsWithRedundantNextVersionTxtSpecification.cs" />
8580
</ItemGroup>
8681
<ItemGroup>
8782
<None Include="packages.config" />
@@ -100,7 +95,9 @@
10095
<Name>GitVersion</Name>
10196
</ProjectReference>
10297
</ItemGroup>
103-
<ItemGroup />
98+
<ItemGroup>
99+
<Folder Include="GitFlow\" />
100+
</ItemGroup>
104101
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
105102
<PropertyGroup>
106103
<PostBuildEvent>
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
namespace GitHubFlowVersion.AcceptanceTests
2+
{
3+
using GitVersion;
4+
using Shouldly;
5+
using Helpers;
6+
using Xunit;
7+
8+
public class MasterTests
9+
{
10+
[Fact]
11+
public void GivenARepositoryWithCommitsButNoTags_VersionShouldBe_0_1()
12+
{
13+
using (var fixture = new RepositoryFixture())
14+
{
15+
// Given
16+
fixture.Repository.MakeACommit();
17+
fixture.Repository.MakeACommit();
18+
fixture.Repository.MakeACommit();
19+
20+
// When
21+
var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath);
22+
23+
result.ExitCode.ShouldBe(0);
24+
result.Output[VariableProvider.FullSemVer].ShouldBe("0.1.0+2");
25+
}
26+
}
27+
28+
[Fact]
29+
public void GivenARepositoryWithNoTagsAndANextVersionTxtFile_VersionShouldMatchVersionTxtFile()
30+
{
31+
using (var fixture = new RepositoryFixture())
32+
{
33+
const string ExpectedNextVersion = "1.0.0";
34+
fixture.Repository.MakeACommit();
35+
fixture.Repository.MakeACommit();
36+
fixture.Repository.MakeACommit();
37+
fixture.Repository.AddNextVersionTxtFile(ExpectedNextVersion);
38+
39+
var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath);
40+
41+
result.ExitCode.ShouldBe(0);
42+
result.Output[VariableProvider.FullSemVer].ShouldBe("1.0.0+2");
43+
}
44+
}
45+
46+
[Fact]
47+
public void GivenARepositoryWithTagAndANextVersionTxtFile_VersionShouldMatchVersionTxtFile()
48+
{
49+
using (var fixture = new RepositoryFixture())
50+
{
51+
const string ExpectedNextVersion = "1.1.0";
52+
const string TaggedVersion = "1.0.3";
53+
fixture.Repository.MakeATaggedCommit(TaggedVersion);
54+
fixture.Repository.MakeCommits(5);
55+
fixture.Repository.AddNextVersionTxtFile(ExpectedNextVersion);
56+
57+
var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath);
58+
59+
result.ExitCode.ShouldBe(0);
60+
result.Output[VariableProvider.FullSemVer].ShouldBe("1.1.0+5");
61+
}
62+
}
63+
64+
[Fact]
65+
public void GivenARepositoryWithTagAndNoNextVersionTxtFile_VersionShouldBeTagWithBumpedPatch()
66+
{
67+
using (var fixture = new RepositoryFixture())
68+
{
69+
const string TaggedVersion = "1.0.3";
70+
fixture.Repository.MakeATaggedCommit(TaggedVersion);
71+
fixture.Repository.MakeCommits(5);
72+
73+
var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath);
74+
75+
result.ExitCode.ShouldBe(0);
76+
result.Output[VariableProvider.FullSemVer].ShouldBe("1.0.4+5");
77+
}
78+
}
79+
80+
[Fact]
81+
public void GivenARepositoryWithTagAndOldNextVersionTxtFile_VersionShouldBeTagWithBumpedPatch()
82+
{
83+
using (var fixture = new RepositoryFixture())
84+
{
85+
const string NextVersionTxt = "1.0.0";
86+
const string TaggedVersion = "1.1.0";
87+
fixture.Repository.MakeATaggedCommit(TaggedVersion);
88+
fixture.Repository.MakeCommits(5);
89+
fixture.Repository.AddNextVersionTxtFile(NextVersionTxt);
90+
91+
var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath);
92+
93+
result.ExitCode.ShouldBe(0);
94+
result.Output[VariableProvider.FullSemVer].ShouldBe("1.1.1+5");
95+
}
96+
}
97+
}
98+
}

AcceptanceTests/GitHubFlow/NoTagsInRepositorySpecification.cs

Lines changed: 0 additions & 47 deletions
This file was deleted.

AcceptanceTests/GitHubFlow/NoTagsInRepositoryWithNextVersionTxtSpecification.cs

Lines changed: 0 additions & 53 deletions
This file was deleted.

AcceptanceTests/GitHubFlow/PullRequestsFixture.cs

Lines changed: 0 additions & 90 deletions
This file was deleted.

0 commit comments

Comments
 (0)