Skip to content

Commit

Permalink
Fixing test-workflow (#21)
Browse files Browse the repository at this point in the history
* renamed DataReaderTest
* renamed workflow
* adjusted tests.yml
* adjusted the test runner for .net framework
  • Loading branch information
tolik518 authored Oct 21, 2023
1 parent 050a01e commit 6aba2d8
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 24 deletions.
40 changes: 21 additions & 19 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
name: dotnet package
name: Tests

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
runs-on: windows-latest

steps:
- uses: actions/checkout@v4
- name: Setup dotnet 4.5.2
uses: actions/setup-dotnet@v3
with:
dotnet-version: "4.5.2"
- name: Display dotnet version
run: dotnet --version
- name: Install dependencies
run: dotnet restore
- name: Test with dotnet
run: dotnet test --logger trx --results-directory "TestResults"
- name: Upload dotnet test results
uses: actions/upload-artifact@v3
with:
name: dotnet-results-4.5.2
path: TestResults
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}

- name: Setup MSBuild
uses: microsoft/[email protected]

- name: Setup NuGet
uses: NuGet/[email protected]

- name: Restore NuGet packages
run: nuget restore SoG_SGreader.sln

- name: Build with MSBuild
run: msbuild /p:Configuration=Release /m /p:BuildInParallel=true /p:BuildIncrementally=true SoG_SGreader.sln

- name: Setup VSTest Console
uses: darenm/[email protected]

- name: Test
run: vstest.console.exe /TestAdapterPath:"packages" SoG_SGreader.Test\bin\Release\SoG_SGreader.Test.dll
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@

namespace SoG_SGreader.Test
{
public class ReaderTests
public class DataReaderTests
{
private static List<Player> players = new List<Player>();

private static Player GetSaveGame(int saveGameNumber)
{
DataReader dataReader = new DataReader();
var txtConsoleMock = new Mock<ITextBoxWrapper>().Object;

string projectDirectory = Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory).Parent.Parent.FullName;
string filePath = Path.Combine(projectDirectory, "SaveGames", saveGameNumber + ".cha");

string projectDirectory = Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory).Parent.Parent.Parent.FullName;

// Exception for GitHub Actions Test Runner
if (Environment.GetEnvironmentVariable("GITHUB_WORKSPACE") != null) {
projectDirectory = Environment.GetEnvironmentVariable("GITHUB_WORKSPACE");
}

string filePath = Path.Combine(projectDirectory, "SoG_SGreader.Test", "SaveGames", saveGameNumber + ".cha");

return dataReader.ReadFromFile(filePath, txtConsoleMock);
}
Expand Down
2 changes: 1 addition & 1 deletion SoG_SGreader.Test/SoG_SGreader.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ReaderTests.cs" />
<Compile Include="DataReaderTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs"/>
</ItemGroup>
<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions SoG_SGreader.Test/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
<package id="xunit.core" version="2.1.0" targetFramework="net45" />
<package id="xunit.extensibility.core" version="2.1.0" targetFramework="net45" />
<package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net45" />
<package id="xunit.runner.visualstudio" version="2.1.0" targetFramework="net45" />
</packages>

0 comments on commit 6aba2d8

Please sign in to comment.