Skip to content

Commit

Permalink
update UT script
Browse files Browse the repository at this point in the history
  • Loading branch information
RayWangQvQ committed May 22, 2024
1 parent ca2a7b2 commit 6feacf7
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 72 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -368,4 +368,7 @@ krew/pkg/utils/fixtures
kustomization.yaml

# cookie config
**/Ray.BiliBiliTool.Console/cookies.json
**/Ray.BiliBiliTool.Console/cookies.json

# ut
coveragereport
11 changes: 10 additions & 1 deletion Ray.BiliBiliTool.sln
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
.gitignore = .gitignore
CHANGELOG.md = CHANGELOG.md
clean.cmd = clean.cmd
common.props = common.props
Dockerfile = Dockerfile
LICENSE = LICENSE
Expand Down Expand Up @@ -139,6 +138,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InfrastructureTest", "test\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ray.BiliBiliTool.Agent.FunctionalTests", "test\Ray.BiliBiliTool.Agent.FunctionalTests\Ray.BiliBiliTool.Agent.FunctionalTests.csproj", "{16F315CF-056A-4B08-8C3C-A3177EA3CBB9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{2B5FD099-CC28-4FBC-9F20-F20300C5DFD2}"
ProjectSection(SolutionItems) = preProject
scripts\clean.cmd = scripts\clean.cmd
scripts\publish.bat = scripts\publish.bat
scripts\publish.ps1 = scripts\publish.ps1
scripts\publish.sh = scripts\publish.sh
scripts\ut.ps1 = scripts\ut.ps1
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -233,6 +241,7 @@ Global
{26B21C30-7358-4E7B-A73E-2272F10A6CA8} = {E9BDDCBE-A57D-4E3B-8252-708088386ADF}
{90C1DB73-B3DB-4BE5-AD1A-5248FE47860E} = {E9BDDCBE-A57D-4E3B-8252-708088386ADF}
{16F315CF-056A-4B08-8C3C-A3177EA3CBB9} = {E9BDDCBE-A57D-4E3B-8252-708088386ADF}
{2B5FD099-CC28-4FBC-9F20-F20300C5DFD2} = {F3DE0D72-426B-4AD9-B3ED-3343CF4223F1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {197319DA-1148-4A99-847C-8B270B6A29AB}
Expand Down
14 changes: 8 additions & 6 deletions scripts/ut.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ dotnet tool install -g dotnet-reportgenerator-globaltool

# 运行单元测试并生成覆盖率报告
Write-Output "Running unit tests and generating coverage report..."
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=./TestResults/coverage.opencover.xml

# 生成 HTML 格式的覆盖率报告
Write-Output "Generating HTML coverage report..."
reportgenerator "-reports:TestResults/*/coverage.opencover.xml" "-targetdir:coveragereport" -reporttypes:Html
# 生成html报告
$coverageFiles = Get-ChildItem -Path . -Recurse -Filter "coverage.cobertura.xml"
$coverageFiles | ForEach-Object { Write-Output $_.FullName }
$reportPaths = ($coverageFiles | ForEach-Object { $_.FullName }) -join ";"
reportgenerator "-reports:$reportPaths" "-targetdir:coveragereport" -reporttypes:Html

# 打开生成的覆盖率报告
Write-Output "Opening coverage report..."
# 检查生成的覆盖率报告文件是否存在
Write-Output "Coverage report generated successfully."
Start-Process "coveragereport/index.htm"
2 changes: 0 additions & 2 deletions test/AppServiceTest/DailyTask/DonateCoinsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ public void Test1()
{
using var scope = Global.ServiceProviderRoot.CreateScope();
var appService = scope.ServiceProvider.GetRequiredService<IDailyTaskAppService>();


}
}
}
35 changes: 0 additions & 35 deletions test/BiliAgentTest/HomeApiTest.cs

This file was deleted.

2 changes: 1 addition & 1 deletion test/InfrastructureTest/WbiHelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void Replace_Test()
string output = Regex.Replace(input, pattern, replacement);
Debug.WriteLine(output);

Assert.Equal(output, "这是一段包含特殊字符@#$%^&的字符串");
Assert.Equal("这是一段包含特殊字符@#$%^&的字符串", output);
}
}
}
46 changes: 23 additions & 23 deletions test/LogTest/TestCoolPush.cs

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions test/LogTest/TestDingTalk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class TestDingTalk
public TestDingTalk()
{
Environment.SetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "Development");
Program.CreateHost(new string[] { });
Program.CreateHost(new string[] { "ENVIRONMENT=Development" });

_key = Global.ConfigurationRoot["Serilog:WriteTo:5:Args:webHookUrl"];
}
Expand All @@ -30,9 +30,10 @@ public void Test2()
{
var client = new DingTalkApiClient(_key);

var title = "这是标题";
var msg = LogConstants.Msg2 + "开始推送";

var result = client.PushMessage(msg);
var result = client.PushMessage(msg, title);
Debug.WriteLine(result.Content.ReadAsStringAsync().Result);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Ray.BiliBiliTool.Infrastructure.Cookie;
using Xunit;
using Ray.BiliBiliTool.Agent.BiliBiliAgent.Services;
using FluentAssertions;

namespace BiliAgentTest
{
Expand Down Expand Up @@ -116,11 +117,15 @@ public void WearMedalWall_Normal_Success()
var biliCookie = scope.ServiceProvider.GetRequiredService<BiliCookie>();

// 猫雷粉丝牌
var request = new WearMedalWallRequest(biliCookie.BiliJct, 365421);
var request = new WearMedalWallRequest(biliCookie.BiliJct, 365421); //todo

BiliApiResponse re = api.WearMedalWall(request).Result;

Assert.True(re.Code == 0);
re.Code.Should().BeOneOf(
0,
1500005
);
}

[Fact]
Expand Down

0 comments on commit 6feacf7

Please sign in to comment.