Skip to content

Commit

Permalink
skip integration test from #15 with Xunit.SkippableFact
Browse files Browse the repository at this point in the history
  • Loading branch information
christianspecht committed Aug 14, 2018
1 parent 3b2ead6 commit 82dd487
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ScmBackup.Tests.Integration/Scm/IScmTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,11 @@ public void RemoteRepositoryExists_ReturnsTrueForExistingRepo()
Assert.True(result);
}

[Fact(Skip="Doesn't finish on AppVeyor, see #15")]
[SkippableFact]
public void RemoteRepositoryExists_ReturnsFalseForNonExistingRepo()
{
Skip.If(TestHelper.RunsOnAppVeyor(), "Doesn't finish on AppVeyor, see #15");

var result = sut.RemoteRepositoryExists(this.NonExistingRepoUrl);
Assert.False(result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="Xunit.SkippableFact" Version="1.3.6" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions src/ScmBackup.Tests/ScmBackup.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<PackageReference Include="RichardSzalay.MockHttp" Version="1.3.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="Xunit.SkippableFact" Version="1.3.6" />
</ItemGroup>

<ItemGroup>
Expand Down
20 changes: 20 additions & 0 deletions src/ScmBackup.Tests/TestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,25 @@ public static string BuildRepositoryName(string userName, string repoName)

return userName + "#" + repoName;
}

/// <summary>
/// Determines whether the tests are currently running on AppVeyor
/// </summary>
/// <remarks>
/// Note: We could use the environment variable "CI" instead, and this would work on Travis as well
/// (https://docs.travis-ci.com/user/environment-variables/#default-environment-variables)
/// 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
/// </remarks>
public static bool RunsOnAppVeyor()
{
// https://www.appveyor.com/docs/environment-variables/
string v = Environment.GetEnvironmentVariable("APPVEYOR");
if (!string.IsNullOrEmpty(v) && v.ToLower()=="true")
{
return true;
}

return false;
}
}
}
8 changes: 8 additions & 0 deletions src/ScmBackup.Tests/TestHelperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,13 @@ public void BuildRepositoryName_ThrowsWhenParameterIsEmpty(string userName, stri
{
Assert.Throws<ArgumentException>(() => TestHelper.BuildRepositoryName(userName, repoName));
}

[Fact]
public void RunsOnAppVeyor_Works()
{
// We can't test the *result* without duplicating the "check whether we are on AppVeyor"
// logic, but we can at least check whether the method executes without errors.
bool result = TestHelper.RunsOnAppVeyor();
}
}
}

0 comments on commit 82dd487

Please sign in to comment.