所有平台的单元测试.net.standard [英] unit testing .net.standard for all platforms

查看:76
本文介绍了所有平台的单元测试.net.standard的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我有一个简单的问题:

我有一个自己的大型库,其中包含许多类.net.standard库。

I have an own large library with many classes as .net.standard library.

现在我想对它进行单元测试。

Now I want to unit test it.

为此,我想使用Visual Studio Testtools UnitTesting。

For this I want to use Visual Studio Testtools UnitTesting.

我想写单位测试代码一次性。

I want to write the unit-test-Code ONE-TIME.

最好是.net.standard-lib。

Best would be as .net.standard-lib.

在此之后我想从.net47,xamarin.droid等提出测试。

After this I want to raise the Tests from .net47, xamarin.droid, and so on.

我不仅可以从.net47测试它 - 因为我从特殊平台注射了。 net47,xamarin.droid-native,uwp。

I cannot only test it from .net47 - because I have injections from Special platforms as .net47, xamarin.droid-native, uwp.

因为.net.standard只是一个规范,这意味着每个平台都实现.net.standard的功能。

Because .net.standard is only a specification this means, that each platform implements the functionality of .net.standard.

所以,我必须从每个平台提出测试。

So, I must raise the Tests from each platform.

如我所见,无法使用

Microsoft.VisualStudio.TestTools.UnitTesting; net.standard.lib中的命名空间。

Microsoft.VisualStudio.TestTools.UnitTesting; Namespace in a net.standard.lib.

那么,怎么做 - 写一次测试 - 测试所有平台?

So, how to do it - write the Tests once - test for all platforms?

备注:我不能使用.net.core - 因为这不是net47或xamarin的.net.standard的实现,也不会进行特定于平台的注入。

Remark: I cannot use .net.core - because this would not be the implemenation of .net.standard for net47 or xamarin, and would not have my platform-specific injections.

谢谢你帮助。

Rowe

推荐答案

嗨Rowe,

感谢您的帖子。

>>那么,怎么做 - 写一次测试 - 测试所有平台?

>> So, how to do it - write the Tests once - test for all platforms?

对于你的情况,你想写一个公共单位测试
测试多平台
。说实话,我认为我们无法做到。由于不同平台的工作方式不同,因为Xamarin还分别包含了针对不同平台的单元测试项目。

To your case, you want to write one common unit test to test multi-platforms. To be honest, I do not think we could make it. As different platforms work differently, as Xamarin also includes the unit test projects for different platform respectively.


您还可以参考 Miljenko的回复,该回复在此主题中给出了类似的意见:

You could also refer to Miljenko’s reply which gave the similar opinion on this thread:

https://forums.xamarin.com/discussion/16971/how-to-test-a-pcl-library-the-right-way?new=1


此相关主题
的主题类似。

希望有所帮助。 

祝你有个美好的一天。

祝你好运,

Fletcher


这篇关于所有平台的单元测试.net.standard的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆