Skip to content

Commit

Permalink
GD-26: Use gdnunt4.test.adapter to run C# tests
Browse files Browse the repository at this point in the history
# Why
With the `gdunit.test.adaper` we can direct run the tests via `dotnet test`

# What
- `Added step `Run C# Tests`
- check `godot-net` to deside beteen GDScript or C# step
  • Loading branch information
MikeSchulze committed Apr 26, 2024
1 parent bd13a93 commit f652cc7
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 8 deletions.
38 changes: 38 additions & 0 deletions .gdunit4_action/.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<MaxCpuCount>1</MaxCpuCount>
<ResultsDirectory>./TestResults</ResultsDirectory>
<TargetFrameworks>net7.0;net8.0</TargetFrameworks>
<TestSessionTimeout>180000</TestSessionTimeout>
<TreatNoTestsAsError>true</TreatNoTestsAsError>
</RunConfiguration>

<LoggerRunSettings>
<Loggers>
<Logger friendlyName="console" enabled="True">
<Configuration>
<Verbosity>detailed</Verbosity>
</Configuration>
</Logger>
<Logger friendlyName="html" enabled="True">
<Configuration>
<LogFileName>test-result.html</LogFileName>
</Configuration>
</Logger>
<Logger friendlyName="trx" enabled="True">
<Configuration>
<LogFileName>test-result.trx</LogFileName>
</Configuration>
</Logger>
</Loggers>
</LoggerRunSettings>

<GdUnit4>
<!-- Additonal Godot runtime parameters-->
<Parameters></Parameters>
<!-- Controlls the Display name attribute of the TestCase. Allowed values are SimpleName and FullyQualifiedName.
This likely determines how the test names are displayed in the test results.-->
<DisplayName>FullyQualifiedName</DisplayName>
</GdUnit4>
</RunSettings>
34 changes: 26 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,12 @@ runs:
echo -e "\e[34m -----------------\e[0m"
- name: 'Restore .Net Project'
if: ${{ !cancelled() }}
if: ${{ !cancelled() && inputs.godot-net == 'true' }}
shell: bash
run: |
if ${{ inputs.godot-net == 'true' }}; then
cd "${{ inputs.project_dir }}"
dotnet restore
dotnet build
fi
cd "${{ inputs.project_dir }}"
dotnet restore
dotnet build
- name: 'Restore Godot project cache'
if: ${{ !cancelled() }}
Expand All @@ -154,8 +152,8 @@ runs:
$GODOT_BIN --path ./ -e --headless --quit-after 2000
echo -e "\e[94mProject cache successfully restored.\e[0m"
- name: 'Run Tests'
if: ${{ !cancelled() }}
- name: 'Run GDScript Tests'
if: ${{ !cancelled() && inputs.godot-net == 'false' }}
env:
GODOT_BIN: '/home/runner/godot-linux/godot'
uses: actions/github-script@v7
Expand All @@ -171,6 +169,26 @@ runs:
};
await runTests(args, core);
- name: 'Run C# Tests'
if: ${{ !cancelled() && inputs.godot-net == 'true' }}
env:
GODOT_BIN: '/home/runner/godot-linux/godot'
shell: bash
run: |
cd "${{ inputs.project_dir }}"
# test if a .runsettings file exists, if not use the action provided default .runsettings
if [ -f .runsettings ]; then
echo "Found `.runsettings` file."
else
echo "No project specific '.runsettings' found, using action default '.runsettings'"
cp ./.gdunit4_action/.runsettings .
fi
ls -lsa ./
dotnet test --settings .runsettings --list-tests
dotnet test --settings .runsettings --results-directory ./reports --logger "trx;LogFileName=results.xml" -v n
ls -lsa ./
ls -lsR ./reports
- name: 'Publish Unit Test Reports'
if: ${{ !cancelled() && inputs.upload-report == 'true' }}
uses: ./.gdunit4_action/publish-test-report
Expand Down

0 comments on commit f652cc7

Please sign in to comment.