Closed stephen-nba closed 6 years ago
@stephen-nba : Thanks for reporting this. This definitely looks like a bug. Does this work if you provide the connection details inline in the DataSource attribute itself instead of in the configuration file?
Wondering if there's been any movement on this? Our tests have quite a few DataSources defined in the same way, so our move to MSTest v2 is on hold for now...
Actually, I seem to have found the fix! The issue was the old configSections declaration at the top of the app.config.
I found that changing the previous one from
<section name="microsoft.visualstudio.testtools" type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
to
<section name="microsoft.visualstudio.qualitytools" type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions"/>
and switching the <microsoft.visualstudio.testtools>
around the dataSources to <microsoft.visualstudio.qualitytools>
makes everything work again!
Great you were able to unblock yourself @smenus. Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral
would have to be changed but microsoft.visualstudio.testtools
should work too. This does look like a different config from the original poster though. Can you share your entire config section please?
Of course!
We went from this
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
<section name="microsoft.visualstudio.testtools" type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</configSections>
<connectionStrings>
<add name="UnitTestConnection" connectionString="AConnectionString" providerName="System.Data.SqlClient" />
</connectionStrings>
<microsoft.visualstudio.testtools>
<dataSources>
<add name="TestDataSource" connectionString="UnitTestConnection" dataTableName="UnitTestTable" dataAccessMethod="Sequential" />
</dataSources>
</microsoft.visualstudio.testtools>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
to this
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
<section name="microsoft.visualstudio.qualitytools" type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions" />
</configSections>
<connectionStrings>
<add name="UnitTestConnection" connectionString="AConnectionString" providerName="System.Data.SqlClient" />
</connectionStrings>
<microsoft.visualstudio.qualitytools>
<dataSources>
<add name="TestDataSource" connectionString="UnitTestConnection" dataTableName="UnitTestTable" dataAccessMethod="Sequential" />
</dataSources>
</microsoft.visualstudio.qualitytools>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
I actually can't remember where I found microsoft.visualstudio.qualitytools
, I think it was somewhere in this repo actually!
Edit: forgot to mention that this was with 1.1.8.
microsoft.visualstudio.testtools
is working perfectly fine with MSTestV2.
i.e. final app.config may look something like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="microsoft.visualstudio.testtools" type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions" />
</configSections>
<connectionStrings>
<add name="MyJetConn" connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=testdatasource.mdb; Persist Security Info=False;" providerName="System.Data.OleDb" />
</connectionStrings>
<microsoft.visualstudio.testtools>
<dataSources>
<add name="MyJetDataSource" connectionString="MyJetConn" dataTableName="MyDataTable" dataAccessMethod="Sequential"/>
</dataSources>
</microsoft.visualstudio.testtools>
</configuration>
@jayaranigarg @Smenus
Could you guys please have a look at my app.config because I am still getting the error, tried replacing testtools with qualitytools as well. Still its not working <?xml version="1.0" encoding="utf-8" ?>
Actually, I seem to have found the fix! The issue was the old configSections declaration at the top of the app.config. I found that changing the previous one from
<section name="microsoft.visualstudio.testtools" type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
to<section name="microsoft.visualstudio.qualitytools" type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions"/>
and switching the<microsoft.visualstudio.testtools>
around the dataSources to<microsoft.visualstudio.qualitytools>
makes everything work again!
Thank you Smenus, these codes also worked for me!
Question
Has anything changed around the DataSource attribute in MSTest v2? Were there any upgrade steps I need to perform?
Description
Have upgraded to MS Test v2 (v 1.1.13). Running my unit test gives:
Steps to reproduce
I have the following attributes on my test:
In my app.config I have
Expected behavior
Test would pass as previously
Actual behavior
As above with exception and stack trace
Environment