Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@ jobs:
run: dotnet test --filter FullyQualifiedName!~ExampleTests --no-build --configuration Release --verbosity normal
- name: Pack
if: startsWith(github.ref, 'refs/tags/v')
run: dotnet pack -p:PackageVersion=${{ env.nugetVersion }} --configuration Release -o ${{github.workspace}}/IntelliTect.SelenatePack --no-build
run: dotnet pack -p:PackageVersion=${{ env.nugetVersion }} --configuration Release -o ${{github.workspace}}/IntelliTect.TestToolsPack --no-build
- name: Upload Artifacts
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v4
with:
name: NuGet
path: ${{github.workspace}}/IntelliTect.SelenatePack
path: ${{github.workspace}}/IntelliTect.TestToolsPack

deploy:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: build-and-test
environment:
name: 'Production'
url: 'https://www.nuget.org/packages/IntelliTect.TestTools.Selenate'
url: 'https://www.nuget.org/packages/IntelliTect.TestTools.TestFramework'
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
Expand All @@ -65,11 +65,11 @@ jobs:
run: |
$tagVersion = "${{ github.ref }}".substring(11)
echo "::set-output name=TAG_VERSION::$tagVersion"
dotnet nuget push IntelliTect.Selenate.$tagVersion.nupkg --source https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }} --skip-duplicate
dotnet nuget push IntelliTect.TestTools.TestFramework.$tagVersion.nupkg --source https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }} --skip-duplicate
id: tag-version
- name: Upload nupkg to Releases
uses: softprops/action-gh-release@v2
with:
fail_on_unmatched_files: true
generate_release_notes: true
files: IntelliTect.Selenate.${{ steps.tag-version.outputs.TAG_VERSION }}.nupkg
files: IntelliTect.TestTools.TestFramework.${{ steps.tag-version.outputs.TAG_VERSION }}.nupkg
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,19 @@ public async Task DependencyWithMissingDependencyThrowsOriginalError()
Assert.IsType<InvalidOperationException>(ex.InnerException);
Assert.Contains("oops", ex.InnerException!.Message, StringComparison.InvariantCultureIgnoreCase);
}

[Fact]
public async Task AsyncBlockThrowsProperlyCatchAndLogException()
{
TestCase tc = new TestBuilder()
.AddAsyncTestBlock<AsyncError>()
.Build();

var ex = await Assert.ThrowsAsync<TestCaseException>(() => tc.ExecuteAsync());
Assert.False(tc.Passed);
Assert.NotNull(ex.InnerException);
Assert.IsType<InvalidOperationException>(ex.InnerException);
Assert.Contains("oops", ex.InnerException!.Message, StringComparison.InvariantCultureIgnoreCase);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using IntelliTect.TestTools.TestFramework.Tests.TestData.Dependencies;
using System;
using System.Threading.Tasks;
using Xunit;

namespace IntelliTect.TestTools.TestFramework.Tests.TestData.TestBlocks
Expand Down Expand Up @@ -70,4 +71,13 @@ public bool Execute(SomeDependency dep)
return true;
}
}

public class AsyncError : TestBlock
{
public async Task Execute()
{
await Task.Delay(1);
throw new InvalidOperationException("Oops");
}
}
}
15 changes: 8 additions & 7 deletions IntelliTect.TestTools.TestFramework/TestCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,9 @@ public async Task ExecuteAsync()
bool runSuccess = await TryRunBlock(tb, testBlockInstance, executeArgs);
if (!runSuccess)
{
if (TestBlockException is null)
{
TestBlockException = new(
TestBlockException ??= new(
$"Unknown error occurred while running test block {tb}. " +
"Please file an issue: https://github.com/IntelliTect/TestTools.TestFramework/issues");
}
break;
}
}
Expand All @@ -122,6 +119,10 @@ public async Task ExecuteAsync()

if (TestBlockException is null)
{
// Note: This likely needs to be moved up above the finally blocks.
// If a test case "passes" i.e. finishes all of its test blocks, we probably need to know that
// in the finally blocks.
// Need to think about how to handle "passed" state if a finally block fails.
Passed = true;
Log?.Info("Test case finished successfully.");
}
Expand Down Expand Up @@ -405,17 +406,17 @@ private async Task<bool> TryRunBlock(Block block, object blockInstance, List<obj
() => FinallyBlockExceptions.Add(ex.InnerException)
);
}
catch (ArgumentException ex)
catch (TargetParameterCountException ex)
{
ex.Data.Add("AdditionalInfo", "Test block failed: Mismatched count between Execute method arguments and supplied dependencies.");
HandleFinallyBlock(
block,
() => TestBlockException = ex,
() => FinallyBlockExceptions.Add(ex)
);
}
catch (TargetParameterCountException ex)
catch (Exception ex)
{
ex.Data.Add("AdditionalInfo", "Test block failed: Mismatched count between Execute method arguments and supplied dependencies.");
HandleFinallyBlock(
block,
() => TestBlockException = ex,
Expand Down
Loading