E2e/unit runtime dotCover code coverage
This commit is contained in:
parent
d7969c40ea
commit
eea03985a3
18 changed files with 57 additions and 39 deletions
18
.github/workflows/dotnet.yml
vendored
18
.github/workflows/dotnet.yml
vendored
|
|
@ -11,21 +11,14 @@ on:
|
|||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
env:
|
||||
CI: true
|
||||
|
||||
steps:
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
- name: Initialize and update submodules
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- name: Initialize and update submodules
|
||||
run: git submodule update --init --recursive
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
|
|
@ -39,9 +32,12 @@ jobs:
|
|||
|
||||
- name: Build projects
|
||||
run: dotnet build --no-restore
|
||||
|
||||
- name: Install JetBrains dotCover CLI
|
||||
run: dotnet tool install --global JetBrains.dotCover.CommandLineTools
|
||||
|
||||
- name: Run unit tests
|
||||
run: dotnet test BTCPayServer.Plugins.Monero.UnitTests/BTCPayServer.Plugins.UnitTests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=json /p:CoverletOutput=../coverage/coverage.json
|
||||
run: dotCover cover-dotnet --TargetArguments="test BTCPayServer.Plugins.UnitTests --no-build" --output=coverage/dotCover.UnitTests.output.dcvr --filters="-:Assembly=BTCPayServer.Plugins.UnitTests;-:Assembly=testhost;-:Assembly=BTCPayServer;-:Class=AspNetCoreGeneratedDocument.*"
|
||||
|
||||
- name: Run integration tests
|
||||
run: docker compose -f BTCPayServer.Plugins.IntegrationTests/docker-compose.yml run tests
|
||||
|
|
@ -54,4 +50,4 @@ jobs:
|
|||
uses: actions/upload-artifact@v4.6.2
|
||||
with:
|
||||
name: coverage-report
|
||||
path: coverage/coverage.cobertura.xml
|
||||
path: coverage/dotcover.xml
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -3,3 +3,4 @@
|
|||
.idea
|
||||
Plugins/packed
|
||||
.vs/
|
||||
coverage
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
@ -29,6 +28,7 @@
|
|||
<ItemGroup>
|
||||
<ProjectReference Include="..\submodules\btcpayserver\BTCPayServer.Abstractions\BTCPayServer.Abstractions.csproj"/>
|
||||
<ProjectReference Include="..\submodules\btcpayserver\BTCPayServer.Tests\BTCPayServer.Tests.csproj"/>
|
||||
<ProjectReference Include="..\Plugins\Monero\BTCPayServer.Plugins.Monero.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemDefinitionGroup>
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ RUN mkdir -p ${MONERO_PLUGIN_FOLDER}
|
|||
RUN cd Plugins/Monero && dotnet build BTCPayServer.Plugins.Monero.sln --configuration ${CONFIGURATION_NAME} /p:RazorCompileOnBuild=true --output ${MONERO_PLUGIN_FOLDER}
|
||||
RUN cd BTCPayServer.Plugins.IntegrationTests && dotnet build --configuration ${CONFIGURATION_NAME} /p:CI_TESTS=true /p:RazorCompileOnBuild=true
|
||||
RUN dotnet tool install --global Microsoft.Playwright.CLI
|
||||
RUN dotnet tool install --global JetBrains.DotCover.CommandLineTools
|
||||
ENV PATH="$PATH:/root/.dotnet/tools"
|
||||
RUN playwright install chromium --with-deps
|
||||
WORKDIR /source/BTCPayServer.Plugins.IntegrationTests
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using Xunit.Abstractions;
|
||||
using BTCPayServer.Tests;
|
||||
|
||||
namespace BTCPayServer.Tests
|
||||
namespace BTCPayServer.Plugins.IntegrationTests.Monero
|
||||
{
|
||||
public class MoneroAndBitcoinIntegrationTestBase : UnitTestBase
|
||||
{
|
||||
|
|
@ -2,7 +2,7 @@ using BTCPayServer.Tests;
|
|||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace BTCPayServer.Plugins.IntegrationTests.MoneroPluginTests;
|
||||
namespace BTCPayServer.Plugins.IntegrationTests.Monero;
|
||||
|
||||
public class MoneroPluginIntegrationTest(ITestOutputHelper helper) : MoneroAndBitcoinIntegrationTestBase(helper)
|
||||
{
|
||||
|
|
@ -1,9 +1,28 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
FILTERS=" "
|
||||
if [ ! -z "$TEST_FILTERS" ]; then
|
||||
FILTERS="--filter $TEST_FILTERS"
|
||||
fi
|
||||
dotCover cover-dotnet \
|
||||
--TargetArguments="test -c ${CONFIGURATION_NAME} $FILTERS . --no-build" \
|
||||
--Output=/coverage/dotCover.IntegrationTests.output.dcvr \
|
||||
--filters="-:Assembly=BTCPayServer.Plugins.IntegrationTests;-:Assembly=testhost;-:Assembly=BTCPayServer;-:Assembly=ExchangeSharp;-:Assembly=BTCPayServer.Tests;-:Assembly=BTCPayServer.Client;-:Assembly=BTCPayServer.Abstractions;-:Assembly=BTCPayServer.Data;-:Assembly=BTCPayServer.Common;-:Assembly=BTCPayServer.Logging;-:Assembly=BTCPayServer.Rating;-:Assembly=Dapper;-:Assembly=Serilog.Extensions.Logging;-:Class=AspNetCoreGeneratedDocument.*"
|
||||
|
||||
dotnet test -c ${CONFIGURATION_NAME} $FILTERS --no-build -v n --logger "console;verbosity=normal" /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=/coverage/coverage.cobertura.xml /p:MergeWith=/coverage/coverage.json< /dev/null
|
||||
dotCover merge \
|
||||
--Source=/coverage/dotCover.IntegrationTests.output.dcvr,/coverage/dotCover.UnitTests.output.dcvr \
|
||||
--Output=/coverage/mergedCoverage.dcvr
|
||||
|
||||
dotCover report \
|
||||
--Source=/coverage/mergedCoverage.dcvr \
|
||||
--ReportType=HTML \
|
||||
--Output=/coverage/mergedCoverage.html \
|
||||
--ReportType=DetailedXML \
|
||||
--Output=/coverage/dotcover.xml
|
||||
|
||||
dotCover report \
|
||||
--Source=/coverage/dotCover.UnitTests.output.dcvr \
|
||||
--ReportType=HTML \
|
||||
--Output=/coverage/unitCoverage.html
|
||||
|
||||
dotCover report \
|
||||
--Source=/coverage/dotCover.IntegrationTests.output.dcvr \
|
||||
--ReportType=HTML \
|
||||
--Output=/coverage/integrationCoverage.html
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsPackable>false</IsPackable>
|
||||
<AssemblyName>BTCPayServer.Plugins.Monero.UnitTests</AssemblyName>
|
||||
<AssemblyName>BTCPayServer.Plugins.UnitTests</AssemblyName>
|
||||
<CoverletOutput>$(MSBuildProjectDirectory)/coverage/</CoverletOutput>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
</PropertyGroup>
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using BTCPayServer.Plugins.Monero.Configuration;
|
||||
using Xunit;
|
||||
|
||||
namespace BTCPayServer.Plugins.Monero.UnitTests.Configuration
|
||||
namespace BTCPayServer.Plugins.UnitTests.Monero.Configuration
|
||||
{
|
||||
public class MoneroLikeConfigurationTests
|
||||
{
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using BTCPayServer.Plugins.Monero.Payments;
|
||||
using Xunit;
|
||||
|
||||
namespace BTCPayServer.Plugins.Monero.UnitTests.Payments
|
||||
namespace BTCPayServer.Plugins.UnitTests.Monero.Payments
|
||||
{
|
||||
public class MoneroLikePaymentDataTests
|
||||
{
|
||||
|
|
@ -1,11 +1,8 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Globalization;
|
||||
using BTCPayServer.Plugins.Monero.RPC.Models;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
using BTCPayServer.Plugins.Monero.RPC.Models;
|
||||
|
||||
namespace BTCPayServer.Plugins.Monero.UnitTests.RPC.Models
|
||||
namespace BTCPayServer.Plugins.UnitTests.Monero.RPC.Models
|
||||
{
|
||||
public class ParseStringConverterTests
|
||||
{
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
using BTCPayServer.Plugins.Monero.RPC;
|
||||
using Xunit;
|
||||
|
||||
namespace BTCPayServer.Plugins.Monero.Tests.RPC
|
||||
namespace BTCPayServer.Plugins.UnitTests.Monero.RPC
|
||||
{
|
||||
public class MoneroEventTest
|
||||
{
|
||||
|
|
@ -2,7 +2,7 @@ using System.Globalization;
|
|||
using Xunit;
|
||||
using BTCPayServer.Plugins.Monero.Utils;
|
||||
|
||||
namespace BTCPayServer.Plugins.Monero.UnitTests.Utils
|
||||
namespace BTCPayServer.Plugins.UnitTests.Monero.Utils
|
||||
{
|
||||
public class MoneroMoneyTests
|
||||
{
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
using System;
|
||||
using Xunit;
|
||||
using BTCPayServer.Plugins.Monero.ViewModels;
|
||||
using BTCPayServer.Payments;
|
||||
using BTCPayServer.Plugins.Monero.ViewModels;
|
||||
using Xunit;
|
||||
|
||||
namespace BTCPayServer.Plugins.Monero.UnitTests.ViewModels
|
||||
namespace BTCPayServer.Plugins.UnitTests.Monero.ViewModels
|
||||
{
|
||||
public class MoneroPaymentViewModelTests
|
||||
{
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
namespace BTCPayServer.Plugins.Altcoins;
|
||||
namespace BTCPayServer.Plugins.Monero;
|
||||
|
||||
public class MoneroLikeSpecificBtcPayNetwork : BTCPayNetworkBase
|
||||
{
|
||||
public int MaxTrackedConfirmation = 10;
|
||||
public string UriScheme { get; set; }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ using Newtonsoft.Json;
|
|||
|
||||
namespace BTCPayServer.Plugins.Monero.RPC.Models
|
||||
{
|
||||
internal class ParseStringConverter : JsonConverter
|
||||
public class ParseStringConverter : JsonConverter
|
||||
{
|
||||
public override bool CanConvert(Type t) => t == typeof(long) || t == typeof(long?);
|
||||
|
||||
|
|
|
|||
|
|
@ -65,10 +65,15 @@ To build and run unit tests, run the following commands:
|
|||
dotnet build btcpay-monero-plugin.sln
|
||||
dotnet test BTCPayServer.Plugins.Monero.UnitTests --verbosity normal
|
||||
```
|
||||
To run unit tests with coverage, run the following command:
|
||||
To run unit tests with coverage, install JetBrains dotCover CLI:
|
||||
|
||||
```bash
|
||||
dotnet test BTCPayServer.Plugins.Monero.UnitTests/BTCPayServer.Plugins.UnitTests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=json /p:CoverletOutput=../coverage/coverage.json
|
||||
dotnet tool install --global JetBrains.dotCover.CommandLineTools
|
||||
```
|
||||
Then run the following command:
|
||||
|
||||
```bash
|
||||
dotCover cover-dotnet --TargetArguments="test BTCPayServer.Plugins.UnitTests --no-build" --ReportType=HTML --Output=coverage/dotCover.UnitTests.output.html --ReportType=detailedXML --Output=coverage/dotCover.UnitTests.output.xml --filters="-:Assembly=BTCPayServer.Plugins.UnitTests;-:Assembly=testhost;-:Assembly=BTCPayServer;-:Class=AspNetCoreGeneratedDocument.*"
|
||||
```
|
||||
|
||||
To build and run integration tests, run the following commands:
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{BDB6EEEA-4
|
|||
README.md = README.md
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BTCPayServer.Plugins.Monero.UnitTests", "BTCPayServer.Plugins.Monero.UnitTests\BTCPayServer.Plugins.UnitTests.csproj", "{BC95362E-D430-4CB4-B888-EE1C054C1E7A}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BTCPayServer.Plugins.UnitTests", "BTCPayServer.Plugins.UnitTests\BTCPayServer.Plugins.UnitTests.csproj", "{BC95362E-D430-4CB4-B888-EE1C054C1E7A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue