一、环境的配置
1.下载二进制包 在华为云上 /home/dotnet-sdk-3.1.415-linux-arm64.tar.gz
2.解压安装DOTNET_FILE=dotnet-sdk-3.1.415-linux-arm64.tar.gz
export DOTNET_ROOT=$(pwd)/dotnet
mkdir -p "$DOTNET_ROOT" && tar zxf "$DOTNET_FILE" -C "$DOTNET_ROOT"
export PATH=$PATH:$DOTNET_ROOT
3.配置yum源。。文件在华为云上。/etc/yum.repos.d/huaweicloud.repo
yum -y install libicu 安装libicu
4. 设置环境变量export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
二、测试程序的配置
1:创建了待测试的文件OnlyTest.cs
using System;
using System.Text;
using System.Collections.Generic;
using NUnit.Framework;
[TestFixture]
public class OnlyTest
{
[Test]
public void MyTest()
{
int a = 10;
Assert.AreEqual(10, a);
}
}
2:下载了文件NuGet.exe和Microsoft.Build.dll(可以从Windows系统中选择.NetCore版本)
采用 nuget.exe v5.8.1 版本,不能是最新地址
NuGet.exe下载最新地址地址示例:https://dist.nuget.org/win-x86-commandline/latest/nuget.exehttps://dist.nuget.org/win-x86-commandline/latest/nuget.exe或者 https://api.nuget.org/downloads/nuget.exe -o nuget.exe
3:运行NuGet来安装NUnit “指定” 版本(有些高版本反而不能用)
mono nuget.exe install NUnit -Version 2.6.4
mono nuget.exe install NUnit.Runners -Version 2.6.4
4:编译.CS代码或者上传Windows下编译的dll文件
mcs OnlyTest.cs -target:library -r:NUnit.2.6.4/lib/nunit.framework.dll -out:OnlyTest.dll
5:执行NUnit测试
mono ./NUnit.Runners.2.6.4/tools/nunit-console.exe OnlyTest.dll -noresult
或者通过MSTest的方式测试也行(不在Mono环境中,在物理机内)dotnet test OnlyTest.dll,但是显示的效果不一样
6:运行结果如下: