您可以用 C# 编写单元测试程序集来测试用 VB 编写的程序集吗?
可能是一个愚蠢的问题,但是您可以用一种语言编写单元测试项目来测试另一种语言的另一个项目吗?
我想将我们的 VB 程序集之一转换为 C#,但想要构建单元测试来验证结果。我尝试设置一个单元测试项目来执行此操作,但我似乎无法访问单元测试中的 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. 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.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一旦在单元测试项目中添加对原始项目或程序集的引用,您应该能够毫无问题地编写单元测试,假设您要测试的成员是公共的。 (如果需要访问标记为内部的类,则可以在原始程序集中添加 InternalsVisibleTo 程序集属性)。
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).
在测试项目中引用 vb.net 程序集或项目,您将有权访问所有公共类和成员。
Reference the vb.net assembly or project in the test project, you'll have access to all public classes and members.