diff --git a/src/ScmBackup.Tests.Integration/Scm/IScmTests.cs b/src/ScmBackup.Tests.Integration/Scm/IScmTests.cs index 0a35e20..8eb263d 100644 --- a/src/ScmBackup.Tests.Integration/Scm/IScmTests.cs +++ b/src/ScmBackup.Tests.Integration/Scm/IScmTests.cs @@ -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); } diff --git a/src/ScmBackup.Tests.Integration/ScmBackup.Tests.Integration.csproj b/src/ScmBackup.Tests.Integration/ScmBackup.Tests.Integration.csproj index 03985bb..ec1835e 100644 --- a/src/ScmBackup.Tests.Integration/ScmBackup.Tests.Integration.csproj +++ b/src/ScmBackup.Tests.Integration/ScmBackup.Tests.Integration.csproj @@ -43,6 +43,7 @@ + diff --git a/src/ScmBackup.Tests/ScmBackup.Tests.csproj b/src/ScmBackup.Tests/ScmBackup.Tests.csproj index ac670a3..7630e56 100644 --- a/src/ScmBackup.Tests/ScmBackup.Tests.csproj +++ b/src/ScmBackup.Tests/ScmBackup.Tests.csproj @@ -25,6 +25,7 @@ + diff --git a/src/ScmBackup.Tests/TestHelper.cs b/src/ScmBackup.Tests/TestHelper.cs index 01497d4..4fa9e98 100644 --- a/src/ScmBackup.Tests/TestHelper.cs +++ b/src/ScmBackup.Tests/TestHelper.cs @@ -67,5 +67,25 @@ public static string BuildRepositoryName(string userName, string repoName) return userName + "#" + repoName; } + + /// + /// Determines whether the tests are currently running on AppVeyor + /// + /// + /// 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 + /// + 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; + } } } diff --git a/src/ScmBackup.Tests/TestHelperTests.cs b/src/ScmBackup.Tests/TestHelperTests.cs index 4dbfcfa..3f684fd 100644 --- a/src/ScmBackup.Tests/TestHelperTests.cs +++ b/src/ScmBackup.Tests/TestHelperTests.cs @@ -51,5 +51,13 @@ public void BuildRepositoryName_ThrowsWhenParameterIsEmpty(string userName, stri { Assert.Throws(() => 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(); + } } }