简体   繁体   English

你能用C#编写单元测试程序集来测试用VB编写的程序集吗?

[英]Can you write a unit test assembly in C# to test against an assembly written in VB?

Probably a dumb question, but can you write a unit test project in one language to test against another project in a different language? 可能是一个愚蠢的问题,但是你能用一种语言编写单元测试项目来测试另一种语言的另一个项目吗?

I'd like to translate one of our VB assemblies into C#, but want to build unit tests to verify the results. 我想将我们的一个VB程序集翻译成C#,但是想要构建单元测试来验证结果。 I've tried to set a unit test project up to do this, but I can't seem to access the VB code within a unit test... I can't figure out if I'm just missing/doing something stupid, or it really isn't allowed. 我试图设置一个单元测试项目来做这个,但我似乎无法在单元测试中访问VB代码...我无法弄清楚我是否只是缺少/做一些愚蠢的事情,或者它确实是不允许的。

EDIT: I'm going to close this as it seems I've gotten my "Yes, it's possible" answer... I am referencing it, so there's gotta be just something I'm not seeing. 编辑:我要关闭这个,因为我似乎已经得到了我的“是的,它是可能的”答案......我正在引用它,所以必须有一些我没有看到的东西。

Once you add a reference to your original project or assembly in your unit test project, you should be able to write a unit test without problems, assuming the members you want to test are public. 在单元测试项目中添加对原始项目或程序集的引用后,您应该能够毫无问题地编写单元测试,假设您要测试的成员是公共的。 (You can add an InternalsVisibleTo assembly attribute in the original assembly if you need access to classes marked internal). (如果需要访问标记为internal的类,可以在原始程序集中添加InternalsVisibleTo程序集属性)。

引用测试项目中的vb.net程序集或项目,您将可以访问所有公共类和成员。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM