如果作为有序测试VS2012的一部分运行,则数据驱动的测试将失败.单独运行时运行正常(不是有序测试的一部分) [英] Data driven tests failing if ran as part of Ordered test VS2012. Whereas running fine when ran separately (not part of ordered test)

查看:72
本文介绍了如果作为有序测试VS2012的一部分运行,则数据驱动的测试将失败.单独运行时运行正常(不是有序测试的一部分)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只有几个数据驱动测试用例,可以在执行时很好地执行 通过VS2012中的测试资源管理器"单独或分组.但是,当为同一组测试创建了有序测试时,执行将失败,并出现以下异常.此外,还观察到非数据驱动的测试在有序测试下运行良好.

I have few Data Driven test cases which executes fine when executed separately or in group through Test Explorer in VS2012. But when created Ordered Test for same set of tests then execution fails with following exception. Also it is observed that non data driven tests are running fine under ordered test.

测试名称:  ******
测试全名:  ******
测试来源:  ******
测试结果:失败
测试时间:  0:00:00.5637297

Test Name: ******
Test FullName: ******
Test Source: ******
Test Outcome: Failed
Test Duration: 0:00:00.5637297

Result1名称:1-  ******(***)
结果1结果:失败
Result1时长:  0:00:00
结果1消息:
单元测试适配器无法连接到数据源或读取数据.有关解决此错误的详细信息,请参见解决数据驱动的单元测试". ( http://go.microsoft.com/fwlink/?LinkId=62412 ) 在MSDN库中.
错误详细信息:错误[HY024] [Microsoft] [ODBC Excel驱动程序]'(未知)'不是有效路径.确保路径名拼写正确,并且已连接到文件所在的服务器.
错误[IM006] [Microsoft] [ODBC驱动程序管理器]驱动程序的SQLSetConnectAttr失败
错误[HY024] [Microsoft] [ODBC Excel驱动程序](未知)"不是有效路径.确保路径名拼写正确,并且已连接到文件所在的服务器.
结果1 StackTrace:

Result1 Name: 1- ****** (***)
Result1 Outcome: Failed
Result1 Duration: 0:00:00
Result1 Message: 
The unit test adapter failed to connect to the data source or to read the data. For more information on troubleshooting this error, see "Troubleshooting Data-Driven Unit Tests" (http://go.microsoft.com/fwlink/?LinkId=62412) in the MSDN Library.
Error details: ERROR [HY024] [Microsoft][ODBC Excel Driver] '(unknown)' is not a valid path.  Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.
ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed
ERROR [HY024] [Microsoft][ODBC Excel Driver] '(unknown)' is not a valid path.  Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.
Result1 StackTrace:

Result2名称:*****
结果2结果:失败
Result2时长:  0:00:00.5637297
结果2消息:
Result2 StackTrace:

Result2 Name: *****
Result2 Outcome: Failed
Result2 Duration: 0:00:00.5637297
Result2 Message:
Result2 StackTrace:

P.S .:使用VSTS数据驱动功能来配置测试

感谢您的帮助!

推荐答案

我没有遇到这种问题,数据驱动测试可以在有序测试中正常运行.

I did not get such issue on my side, the data driven test can run fine within an ordered test.

我怀疑您的数据源文件已更改,或者DataSource中的路径不正确.请检查数据源文件和数据驱动测试.

I doubt that your data source file was changed or the path in DataSource was not correct. Please check the data source file and data driven test.

这是我这边的DataSource属性,数据源文件是使用testsettings文件部署的:

This is the DataSource attribute on my side, the data source file was deployed using testsettings file:

[ 数据源 "System.Data.Odbc" "Dsn = Excel文件; Driver = {Microsoft Excel驱动程序(* .xls)}; dbq = | DataDirectory | \\ data.xlsx; defaultdir = .; driverid = 790; maxbuffersize = 2048; pagetimeout = 5; readonly = true" " Sheet1

[DataSource("System.Data.Odbc", "Dsn=Excel Files;Driver={Microsoft Excel Driver (*.xls)};dbq=|DataDirectory|\\data.xlsx;defaultdir=.;driverid=790; maxbuffersize=2048;pagetimeout=5;readonly=true", "Sheet1


" DataAccessMethod .顺序)]
", DataAccessMethod.Sequential)]

谢谢


这篇关于如果作为有序测试VS2012的一部分运行,则数据驱动的测试将失败.单独运行时运行正常(不是有序测试的一部分)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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