Skip to content

Commit 82dd487

Browse files
skip integration test from #15 with Xunit.SkippableFact
1 parent 3b2ead6 commit 82dd487

File tree

5 files changed

+33
-1
lines changed

5 files changed

+33
-1
lines changed

src/ScmBackup.Tests.Integration/Scm/IScmTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,11 @@ public void RemoteRepositoryExists_ReturnsTrueForExistingRepo()
217217
Assert.True(result);
218218
}
219219

220-
[Fact(Skip="Doesn't finish on AppVeyor, see #15")]
220+
[SkippableFact]
221221
public void RemoteRepositoryExists_ReturnsFalseForNonExistingRepo()
222222
{
223+
Skip.If(TestHelper.RunsOnAppVeyor(), "Doesn't finish on AppVeyor, see #15");
224+
223225
var result = sut.RemoteRepositoryExists(this.NonExistingRepoUrl);
224226
Assert.False(result);
225227
}

src/ScmBackup.Tests.Integration/ScmBackup.Tests.Integration.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
4444
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
4545
<PackageReference Include="xunit" Version="2.4.0" />
46+
<PackageReference Include="Xunit.SkippableFact" Version="1.3.6" />
4647
</ItemGroup>
4748

4849
</Project>

src/ScmBackup.Tests/ScmBackup.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<PackageReference Include="RichardSzalay.MockHttp" Version="1.3.0" />
2626
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
2727
<PackageReference Include="xunit" Version="2.4.0" />
28+
<PackageReference Include="Xunit.SkippableFact" Version="1.3.6" />
2829
</ItemGroup>
2930

3031
<ItemGroup>

src/ScmBackup.Tests/TestHelper.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,25 @@ public static string BuildRepositoryName(string userName, string repoName)
6767

6868
return userName + "#" + repoName;
6969
}
70+
71+
/// <summary>
72+
/// Determines whether the tests are currently running on AppVeyor
73+
/// </summary>
74+
/// <remarks>
75+
/// Note: We could use the environment variable "CI" instead, and this would work on Travis as well
76+
/// (https://docs.travis-ci.com/user/environment-variables/#default-environment-variables)
77+
/// But we probably need to distinguish between CI providers (should we ever use more than one) because some issues (like #15) could be provider-specific
78+
/// </remarks>
79+
public static bool RunsOnAppVeyor()
80+
{
81+
// https://www.appveyor.com/docs/environment-variables/
82+
string v = Environment.GetEnvironmentVariable("APPVEYOR");
83+
if (!string.IsNullOrEmpty(v) && v.ToLower()=="true")
84+
{
85+
return true;
86+
}
87+
88+
return false;
89+
}
7090
}
7191
}

src/ScmBackup.Tests/TestHelperTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,13 @@ public void BuildRepositoryName_ThrowsWhenParameterIsEmpty(string userName, stri
5151
{
5252
Assert.Throws<ArgumentException>(() => TestHelper.BuildRepositoryName(userName, repoName));
5353
}
54+
55+
[Fact]
56+
public void RunsOnAppVeyor_Works()
57+
{
58+
// We can't test the *result* without duplicating the "check whether we are on AppVeyor"
59+
// logic, but we can at least check whether the method executes without errors.
60+
bool result = TestHelper.RunsOnAppVeyor();
61+
}
5462
}
5563
}

0 commit comments

Comments
 (0)