Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing test-workflow #21

Merged
merged 23 commits into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
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>