VS 2013单元测试不工作=>设置执行上下文时出错 [英] VS 2013 unit test not working => error while setting up execution context

查看:286
本文介绍了VS 2013单元测试不工作=>设置执行上下文时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图第一次为我的私人项目实施一些单元组件测试。我看了一些视频,然后我尝试了一步一步的指导,如何正确地写测试。我的第一步工作正常,但是当我尝试在我的c ++项目中实现单元测试项目(分为两个项目,一个项目创建一个DLL,另一个项目使用它)我收到一个错误,我不知道什么完全是错误的,因为错误消息不是真的有用。

I tried the first time to implement some unit component tests for an private project of mine. I watched some videos about that and then I tried a step by step guide, how to write tests correctly. My first steps are working fine, but when I try to implement a unit test project in my c++ project (splitted into two projects, one project creates a DLL and the other project used it) I get an error and I don't know what exactly is wrong, because the error message isn't really helpful.

首先我的代码。此代码工作正常,没有任何问题:

First my code. This code works fine, without any issues:

TEST_METHOD(TestMethod1)
{
    Assert::AreEqual(1, 1);
}

但是当我添加我的包含在DLL项目中使用我的类时测试方法显示以上失败,我不知道为什么。我得到的唯一的消息是这个(这是德语,对不起,但我没有发现类似的错误信息在网上用英语写的):

But when I add my include for using my classes written in the DLL project this test method showed above failed and I don't know why. The only message I get is this (it is in German, sorry for that, but I don't find a similar error message in the web written in English):

Testname         :  TestMethod1
Test FullName    :  TestUnit::UnitTest1::TestMethod1
Testquelle       :  ...\unittest1.cpp Zeile 12
Testergebnis     :  Fehler
Testdauer        :  0:00:00

Ergebnis Meldung :  Fehler beim Einrichten des Ausführungskontexts 
                    zur Ausführung des Tests

(这意味着设置执行上下文以进行测试执行时出错)

(That means something like "Error while setting up the execution context for test execution")

所以...我google了一下,我发现一些关于这样的错误的信息,他们说,也许有一些链接错误或链接器没有找到LIB / DLL,但我比较我的依赖和库引用与我的(工作)项目使用DLL和依赖项和引用是一样的。

So ... I googled a bit and I found some information about such errors and they say, maybe there is something linked wrong or the linker don't find the LIB/DLL, but I compared my dependencies and library references with my (working) project that uses the DLL and the dependencies and references are the same.

现在我有点困惑,我不知道如何解决这个错误。
有人有想法吗?

Now I'm a bit confused and I don't know how to fix that error. Does someone have an idea?

推荐答案

至少在尝试寻找解决方案的几个小时和几天之后,我解决了问题,但请不要问我怎么样。
我阅读了有关类似问题的文章 HERE 和I使用这个工具,它说有一些文件我的项目没有找到像libpng16.lib和 MICROSOFT.VISUALSTUDIO.TESTTOOLS.CPPUNITTESTFRAMEWORK.DLL。删除我的libpng16引用(因为我不再需要它),项目仍然不起作用。将cppunittestframework.lib添加到我的项目(参考)并添加文件夹(我认为,Visual Studio的UnitTest文件夹通过标准链接)测试运行完美。再次删除这两个引用后,测试也工作。
不知道会发生什么,我不能说出问题的解决方案,但现在我的测试正在运行。
希望将来仍然可以工作...

At least, after hours and days of trying and searching for a solution, I solved the problem, but please don't ask me how. I read an article about similar problems HERE and I used THIS tool and it said there are some files my project doesn't find like "libpng16.lib" and "MICROSOFT.VISUALSTUDIO.TESTTOOLS.CPPUNITTESTFRAMEWORK.DLL". After removing my libpng16 reference (because I don't need it anymore) the project still doesn't work. After adding the cppunittestframework.lib to my project (reference) and adding the folder (I thought, this UnitTest folder of visual studio is linked by standard) the test running perfectly. After removing this two references again, the test also working. Don't know what happens and I cannot say what was the solution for the problem, but now my tests are working. Hopefully it will still work in future ...

这篇关于VS 2013单元测试不工作=>设置执行上下文时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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