I am following up the below link and setting a CI set up.
https://blogs.msdn.microsoft.com/visualstudioalm/2015/05/29/testing-in-continuous-integration-and-continuous-deployment-workflows/
The issue I am facing here is with respect to the test settings file. The test are running fine locally. But not remotely when running it, I am getting all test failures.
I believe this is because of the spreadsheet ( where the test data resides ) and the test settings file.
My test settings file is below
<?xml version="1.0" encoding="UTF-8"?>
<TestSettings name="UITestSettings" id="1623gdcf4-f2af-496f-b65h4-fe25w6c4e49cb" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
<Description>These are default test settings for a remote test run.</Description>
<Deployment>
<DeploymentItem filename="XXX\TestData\LocationData.xls" />
<DeploymentItem filename="XXX\TestData\UITestData.xls" />
</Deployment>
<Execution parallelTestCount="0">
<Timeouts runTimeout="36610000" testTimeout="36610000" />
<TestTypeSpecific>
<UnitTestRunConfig testTypeId="13cdcs9d9-ddb5-4fa4-a97d-d965ccdfc6d4b">
<AssemblyResolution>
<TestDirectory useLoadContext="true" />
</AssemblyResolution>
</UnitTestRunConfig>
<WebTestRunConfiguration testTypeId="4ess7599fa-5ecb-43e9-a887-cd63cfdf72d207">
<Browser name="Internet Explorer 9.0" MaxConnections="6">
<Headers>
<Header name="User-Agent" value="Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" />
<Header name="Accept" value="*/*" />
<Header name="Accept-Language" value="{{$IEAcceptLanguage}}" />
<Header name="Accept-Encoding" value="GZIP" />
</Headers>
</Browser>
</WebTestRunConfiguration>
</TestTypeSpecific>
<AgentRule name="LocalMachineDefaultRole">
</AgentRule>
</Execution>
<Properties>
<Property name="TestSettingsUIType" value="UnitTest" />
</Properties>
</TestSettings>
All test failed with this error
Data source 'XXX.YYY.aboutThemRecommendationFirstQuarterFlows' cannot be found in the test configuration settings
But I have the settings file in the build steps ( in Run functional Step )
Is there anything I am missing. Any help would be great as I am struggling to find a solutions.
Thanks
According to the error message, it seems that you are referring to a data source named as "XXX.YYY.aboutThemRecommendationFirstQuarterFlows" which does not exist in "App.config" file test configuration settings.
For example, I have a test method use "MyExcelDataSourceTTT" data source:
[TestMethod]
[DataSource("MyExcelDataSourceTTT")]
public void TestMethod1()
{
Assert.AreEqual(TestContext.DataRow["1"].ToString(),"1");
}
But in the App.config file, I only have "MyExcelDataSource" data source. "MyExcelDataSourceTTT" data source does not exist:
<?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="ExcelConnection" connectionString="Dsn=Excel Files;dbq=.\testdata.xlsx;defaultdir=.; driverid=790;maxbuffersize=2048;pagetimeout=5" providerName="System.Data.Odbc" />
</connectionStrings>
<microsoft.visualstudio.testtools>
<dataSources>
<add name="MyExcelDataSource" connectionString="ExcelConnection" dataTableName="Sheet1$" dataAccessMethod="Sequential"/>
</dataSources>
</microsoft.visualstudio.testtools>
</configuration>
Now, when run the testing, you will get "Data source 'MyExcelDataSourceTTT' cannot be found in the test configuration settings.." error message.
Related
I have to migrate my existing tests from Specflow+Runner to Specflow+xUnit and for the same I'have been stuck on converting the .runsettings and .srprofile files so that they can be used with Specflow+xUnit.
Has anyone done this conversion or can help me with this ?
Existing .runsettings file :
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- Configurations for SpecRun -->
<SpecRun>
<Profile>DEV.srprofile</Profile>
<!-- SpecRun uses VisualStudo.srprofile or TFS.srprofile by default, or the Default.srprofile if these don't exist.
<Profile>MyProfile.srprofile</Profile> -->
<!-- SpecRun generates a report file based on the project name and the current timestamp by default.
<ReportFile>CustomReport.html</ReportFile>-->
<GenerateSpecRunTrait>false</GenerateSpecRunTrait> <!-- Set this to "true" to generate a "SpecRun" trait for all tests discovered by SpecRun (useful when the solution contains other tests too) -->
<GenerateFeatureTrait>false</GenerateFeatureTrait> <!-- Set this to "true" to generate a feature trait for all scenarios (othervise the feature goruping can be used as "class") -->
</SpecRun>
</RunSettings>
Existing .srprofile file :
<?xml version="1.0" encoding="utf-8"?>
<TestProfile xmlns="http://www.specflow.org/schemas/plus/TestProfile/1.5">
<Settings projectName="example" />
<Execution stopAfterFailures="3" testThreadCount="1" testSchedulingMode="Sequential" />
<!-- For collecting by a SpecRun server update and enable the following element. For using the
collected statistics, set testSchedulingMode="Adaptive" attribute on the <Execution> element.
<Server serverUrl="http://specrunserver:6365" publishResults="true" />
-->
<TestAssemblyPaths>
<TestAssemblyPath>example.dll</TestAssemblyPath>
</TestAssemblyPaths>
<DeploymentTransformation>
<Steps>
<ConfigFileTransformation configFile="App.config">
<Transformation>
<![CDATA[<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="baseUrl" value="<sample URL>" xdt:Locator="Match(key)" xdt:Transform="SetAttributes" />
<add key="shortWait" value="15" xdt:Locator="Match(key)" xdt:Transform="SetAttributes" />
<add key="longWait" value="25" xdt:Locator="Match(key)" xdt:Transform="SetAttributes" />
</appSettings>
</configuration>
]]>
</Transformation>
</ConfigFileTransformation>
</Steps>
</DeploymentTransformation>
</TestProfile>
I came for advice.I'm trying to connect to the database through C#.But I have a problem with the App config file.It keeps throwing the App exception:,,
Configuration system failed to initialize
".I tried to add ,as advised here:Configuration System Failed To Initialize , but with no positive result.
So I wonder,if there is still a problem in the code,but I rather think that the problem is with the App config file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<add key="DataSource" value=" My Database'IP adress "/>
<add key="Database" value="My database Name"/>
<add key="Name" value="User name"/>
<add key="Password" value="Password"/>
</configuration>
It seems like you're missing the appSettings element that wraps your key-value collection. It should look more like the following:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="DataSource" value=" My Database'IP adress "/>
<add key="Database" value="My database Name"/>
<add key="Name" value="User name"/>
<add key="Password" value="Password"/>
</appSettings>
</configuration>
I am writing a simple reporting application that pulls data from a SQL database on an external server, and sends out HTML email messages based on said data.
The project builds and executes perfectly 99% of the time, with the exception being after I modify the app.config file. The very first build and run (in Visual Studio 2012 Pro) after modifying the app.config file yields the following error:
"The operation could not be completed. The process cannot access the file because it is being used by another process."
The build succeeds, but this error is generated immediately following build.
I have found several other users with a similar problem, and the solutions were varied. None had the same error for the same reason. A number of people attributed the error to a VS debugger issue.
Has anyone else experienced the same issue, or does anyone know what may cause this? Note that I get the same error in both Debug and Release. The same error is generated even if the connection string is not encrypted.
I have included the app.config file below, as well as all code that accesses config information.
Config File:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<appSettings>
<add key="minimum_days" value="40"/>
<add key="maximum_days" value="70"/>
</appSettings>
<connectionStrings configProtectionProvider="RsaProtectedConfigurationProvider">
<EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element"
xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<KeyName>Rsa Key</KeyName>
</KeyInfo>
<CipherData>
<CipherValue>......ciphertext...</CipherValue>
</CipherData>
</EncryptedKey>
</KeyInfo>
<CipherData>
<CipherValue>...ciphertext...</CipherValue>
</CipherData>
</EncryptedData>
</connectionStrings>
</configuration>
Access Code:
private int min_threshold = Convert.ToInt32(ConfigurationManager.AppSettings.Get("minimum_days"));
private int max_threshold = Convert.ToInt32(ConfigurationManager.AppSettings.Get("maximum_days"));
private string connection_string = ConfigurationManager.ConnectionStrings["str1"].ConnectionString;
I am trying to build Test class of data-driven unit tests in C#. I want to use 3 databases: one from SQL, one from Access and one from Excel.
This is my app.config file:
<?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"/>
</configSections>
<connectionStrings>
<add name="MyJetConn"
connectionString="Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=H:\SQA\CoolMath\CoolMath\Database1.accdb;
Persist Security Info=False;"
providerName="System.Data.OleDb" />
<add name="MyExcelConn"
connectionString="Dsn=Excel Files;
dbq=H:\SQA\CoolMath\CoolMath\CoolMathExcelDataTable.xlsx;
defaultdir=.;
driverid=1046;
maxbuffersize=2048;
pagetimeout=5"
providerName="System.Data.Odbc" />
<add name="MSSQLConn"
connectionString="Data Source=H:\SQA\CoolMath\CoolMath\SQLExpress;
Initial Catalog=MSSQLDB;
Integrated Security=SSPI;"
providerName="System.Data.SqlClient" />
</connectionStrings>
<microsoft.visualstudio.testtools>
<dataSources>
<add name="MyJetDataSource"
connectionString="MyJetConn"
dataTableName="CoolMathAcessDataTable"
dataAccessMethod="Sequential"/>
<add name="MyExcelDataSource"
connectionString="MyExcelConn"
dataTableName="Sheet1$"
dataAccessMethod="Sequential"/>
<add name="MSSQLDataSource"
connectionString="MSSQLConn"
dataTableName="dbo.CoolMathDataTable"
dataAccessMethod="Sequential"/>
</dataSources>
</microsoft.visualstudio.testtools>
</configuration>
When I try to run the tests, they all fail with the message:
"Data source cannot be found in the test configuration settings".
I can't see what am I doing wrong, perhaps it is the location of the databases? (they all in the same library as the code project and the XML file).
Above the Unit Tests I've place the following attributes:
[TestMethod()] [DeploymentItem("CoolMath\\CoolMathExcelDataTable.xlsx")]
[DataSource("MyExcelDataSource")]
With Visual Studio the relative paths for DataSources have moved.
I'm using XML files, but I would not be surprised if the xlsx files have the same problem. I had to use the following to get the files to work
[DeploymentItem("TestData\\Search.xml")]
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML",
#"|DataDirectory|\\..\TestData\Search.xml",
"Row",
DataAccessMethod.Sequential)]
Note the path in line 2, it is starts with a \..\
This is because relative paths changed from Solution to Project (or visa versa). Test_Data is a folder at the top of the project.
I'm performing a migration of database, SQL Server to Oracle, in a C# application. The application mentioned, is using Entity Framework to access the database.
In this database there's a procedure that returns a "ComplexType", I researched and found that Oracle does not understand the "ComplexType" and I need to perform the mapping of the output parameter in web.config, then:
<oracle.manageddataaccess.client>
<version number="*">
<implicitRefCursor>
<storedProcedure schema="ALERTA_MPLUS" name="PR_CONSULTA_DADOS_ROBO">
<refCursor name="CV_1">
<bindInfo mode="Output" />
<metadata columnOrdinal="0" columnName="Broker" baseColumnName="Broker" baseSchemaName="ALERTA_MPLUS" baseTableName="tt_Resultado_Final" nativeDataType="Varchar2" providerType="Varchar2" columnSize="50" />
<metadata columnOrdinal="1" columnName="Companhia" baseColumnName="Companhia" baseSchemaName="ALERTA_MPLUS" baseTableName="tt_Resultado_Final" nativeDataType="Varchar2" providerType="Varchar2" columnSize="100" />
<metadata columnOrdinal="2" columnName="Metrica" baseColumnName="Metrica" baseSchemaName="ALERTA_MPLUS" baseTableName="tt_Resultado_Final" nativeDataType="Varchar2" providerType="Varchar2" columnSize="50" />
<metadata columnOrdinal="3" columnName="Q1" baseColumnName="Q1" baseSchemaName="ALERTA_MPLUS" baseTableName="tt_Resultado_Final" nativeDataType="NVarchar2" providerType="NVarchar2" columnSize="50" />
<metadata columnOrdinal="4" columnName="Q2" baseColumnName="Q2" baseSchemaName="ALERTA_MPLUS" baseTableName="tt_Resultado_Final" nativeDataType="NVarchar2" providerType="NVarchar2" columnSize="50" />
<metadata columnOrdinal="5" columnName="Q3" baseColumnName="Q3" baseSchemaName="ALERTA_MPLUS" baseTableName="tt_Resultado_Final" nativeDataType="NVarchar2" providerType="NVarchar2" columnSize="50" />
<metadata columnOrdinal="6" columnName="Q4" baseColumnName="Q4" baseSchemaName="ALERTA_MPLUS" baseTableName="tt_Resultado_Final" nativeDataType="NVarchar2" providerType="NVarchar2" columnSize="50" />
</refCursor>
</storedProcedure>
</implicitRefCursor>
</version>
</oracle.manageddataaccess.client>
This mapping worked perfectly in the development environment, but when I passed the application for approval gave the following error:
I've tried some solutions but none was successful:
ODAC installed on the server approval;
Searching, I found the Oracle documentation that indicates the mapping that way:
<oracle.dataaccess.client>
<settings>
<add name="ALERTA_MPLUS.PR_CONSULTA_DADOS_ROBO.RefCursor.CV_1" value="implicitRefCursor bindinfo='mode=Output'" />
<add name="ALERTA_MPLUS.PR_CONSULTA_DADOS_ROBO.RefCursorMetaData.CV_1.Column.0" value="implicitRefCursor metadata='ColumnName=Broker;BaseColumnName=Broker;BaseSchemaName=ALERTA_MPLUS;BaseTableName=tt_Resultado_Final;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
<add name="ALERTA_MPLUS.PR_CONSULTA_DADOS_ROBO.RefCursorMetaData.CV_1.Column.1" value="implicitRefCursor metadata='ColumnName=Companhia;BaseColumnName=Companhia;BaseSchemaName=ALERTA_MPLUS;BaseTableName=tt_Resultado_Final;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
<add name="ALERTA_MPLUS.PR_CONSULTA_DADOS_ROBO.RefCursorMetaData.CV_1.Column.2" value="implicitRefCursor metadata='ColumnName=Metrica;BaseColumnName=Metrica;BaseSchemaName=ALERTA_MPLUS;BaseTableName=tt_Resultado_Final;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
<add name="ALERTA_MPLUS.PR_CONSULTA_DADOS_ROBO.RefCursorMetaData.CV_1.Column.3" value="implicitRefCursor metadata='ColumnName=Q1;BaseColumnName=Q1;BaseSchemaName=ALERTA_MPLUS;BaseTableName=tt_Resultado_Final;NATIVEDATATYPE=NVarchar2;ProviderType=NVarchar2'" />
<add name="ALERTA_MPLUS.PR_CONSULTA_DADOS_ROBO.RefCursorMetaData.CV_1.Column.4" value="implicitRefCursor metadata='ColumnName=Q2;BaseColumnName=Q2;BaseSchemaName=ALERTA_MPLUS;BaseTableName=tt_Resultado_Final;NATIVEDATATYPE=NVarchar2;ProviderType=NVarchar2'" />
<add name="ALERTA_MPLUS.PR_CONSULTA_DADOS_ROBO.RefCursorMetaData.CV_1.Column.5" value="implicitRefCursor metadata='ColumnName=Q3;BaseColumnName=Q3;BaseSchemaName=ALERTA_MPLUS;BaseTableName=tt_Resultado_Final;NATIVEDATATYPE=NVarchar2;ProviderType=NVarchar2'" />
<add name="ALERTA_MPLUS.PR_CONSULTA_DADOS_ROBO.RefCursorMetaData.CV_1.Column.6" value="implicitRefCursor metadata='ColumnName=Q4;BaseColumnName=Q4;BaseSchemaName=ALERTA_MPLUS;BaseTableName=tt_Resultado_Final;NATIVEDATATYPE=NVarchar2;ProviderType=NVarchar2'" />
</settings>
</oracle.dataaccess.client>
This is code return the following error (in all environments):
ORA-06550: line 1, colunm 8: PLS-00306:
wrong number or types of arguments in call to
'PR_CONSULTA_DADOS_ROBO' ORA-06550: line 1, colunm 8: PL/SQL:
Statement ignored;
I published the application on another machine (another developer) and also worked;
Some information that I think are necessary:
Visual Studio 2013;
Oracle.DataAcess.dll version 4.121.1.0;
Oracle.ManagedDataAccess.dll version 4.121.1.0;
ISS 7.0;
Pool - Enable 32-bit Applications true;
If you can help me...
Very thanks in advance!
After many trials and errors managed to solve. I do not know if it is the best solution but worked.
In machine.config exists a definition of <oracle.manageddataaccess.client>:
<configSections>
<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</configSections>
So I added this declaration in web.config and it worked perfectly.
I had the same issue and this showed me the way to a solution.
The cause of the issue was that I had installed the OracleManagedDataAccessClient through NUGET but someone else had done a native install of the client. When the client was installed, it created an entry in the Machine.Config. When NUGET installed it created an entry in the Web.config. When trying to execute, I received an error that the section for:
<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
Already existed. I commented it out and my service worked but Oracle would fail with the error:
"PLS-00306: wrong number or types of arguments in call"
When the client was installed it was an earlier version of Oracle so the entry in the Machine.config was:
<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.**1**.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
Since I commented the entry in web.config, the application used the machine.config entry which did not match the actual version.
I modified the entry in the machine.config to match the web.config and everything now works.