简体   繁体   English

VS2008单元测试项目的错误

[英]VS2008 Unit Test Project bugs

I'm using VS 2008 Developer Edition and am finding some bugs with the Test Projects. 我正在使用VS 2008开发人员版,并且在测试项目中发现了一些错误。

I am getting one error that doesn't make sense - I have a class called 'Foo' which I need to test and created the blank test class automatically. 我收到一个没有道理的错误-我有一个名为“ Foo”的类,需要对其进行测试并自动创建空白测试类。

Foo takes 3 paremeters in its constructor - IBar, IBaz, IBang. Foo在其构造函数IBar,IBaz,IBang中采用3个参数。

When I write a test case, I will Dim foo as New Foo(bar,baz,bang), and I will sometimes get an error that says = 'Type IBang could not be implicitly converted to IBang'. 当我写一个测试用例时,我会将foo设为New Foo(bar,baz,bang),有时会收到一条错误消息,指出='无法将类型IBang隐式转换为IBang'。 This error does not make any sense. 此错误没有任何意义。

Even more odd - if I switch to an instance of Foo_Accessor() instead, the error goes away. 更奇怪的是-如果我改用Foo_Accessor()实例,则错误消失。 I've played with the references and then I can eventually fix the above error - but then I get the same error for my Foo_Accessor() class! 我已经使用了引用,然后最终可以修复上述错误-但是我的Foo_Accessor()类却遇到了相同的错误!

I clean, rebuild, and sometimes the error will go away - but then I get the error 'Foo_Accessor' is not defined. 我清理,重建,有时错误会消失-但随后我得到未定义错误“ Foo_Accessor”。 Now I go to the Foo class and do 'create accessor' again - again, it still gives the same error. 现在,我进入Foo类,再次执行“创建访问器”-再次,它仍然给出相同的错误。 So at this point I'm stuck and my solution won't compile, and the only thing I did was add a new test case through visual studio! 因此,在这一点上,我陷入了困境,解决方案无法编译,而我唯一要做的就是通过Visual Studio添加新的测试用例!

Has anyone seen these issues and could please help? 有没有人看到这些问题,请帮忙吗?

Also - I have tried everything, including instructions from MS such as - renaming the type, re-referencing the project / in different ways, unloading the projects, etc, etc.. still I wind up with either the 'ifoo cannot convert to ifoo' bug or Foo_Accessor is not defined bug... I'm about to just break down and give the damned property I have to check a ReadOnly accessor... ! 另外-我已经尝试了一切,包括来自MS的指令,例如-重命名类型,以不同方式重新引用项目/,卸载项目等。依旧,我还是无法将'ifoo转换为ifoo错误或Foo_Accessor未定义错误...我将要分解,给该死的属性,我必须检查一个ReadOnly访问器...!

It's hard to say for certain but it sounds like you have a problem with your references being setup incorrectly. 很难肯定地说,但这听起来像是您的引用设置有问题。 What's likely happening here is that one of the references between your projects is setup as a DLL reference vs. a project reference. 这里可能发生的情况是,项目之间的引用之一被设置为DLL引用还是项目引用。 This can confuse the type system into thinking that Bang from the project and Bang from the DLL are actually different types. 这可能会使类型系统混淆,以为来自项目的Bang和来自DLL的Bang实际上是不同的类型。

I would delete all references between my projects. 我将删除项目之间的所有引用。 Then go add all of them back again being careful to select the project from the project tab of the add reference dialog vs. the Browse one. 然后再次添加所有它们,注意从添加引用对话框的项目选项卡中选择项目,而不是浏览一个。 This should fix your problem. 这应该可以解决您的问题。

Is this a multi-language project or just a single language project? 这是多语言项目还是单语言项目? I've found this type of problem is more likely to occur in a multi-language project but it's certainly happened in a single language one. 我发现这种类型的问题更有可能在多语言项目中发生,但肯定是在一种语言中发生的。

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

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