What is the right way to set connection string for integrated testing?
I feel like I'm missing something here. We are trying to run integrated tests but can't seem to get the connection string configured. We are targeting a specific test assembly (class library) which has config transforms in place (using SlowCheetah). We receive a bunch of these errors when executing the tests: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified).
It doesn't appear that the testing infrastructure is using the
config file for the connection string varibles. We tried out output
the connections string in the console during execution of the tests
via
ConfigurationManager.ConnectionStrings["myConnectionStringName"]
but that returned null. So, what is the correct way to set the
connection string for integrated testing with AppVeyor?
Thanks,
Vinney
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Feodor Fitsner on 16 Jul, 2014 05:54 AM
The way of setting connection string depends on test framework and test runner you use. Sample connection strings can be found here: http://www.appveyor.com/docs/services-databases
Let me know if you have questions.
2 Posted by Vinney Kelly on 16 Jul, 2014 06:32 AM
Thanks for your reply. We've found the sample connection settings as seen in the link provided. Where were uncertain is understanding where to put these variables so that the test runner will pick them up. Our primary test framework is nunit though we also have some SpecFlow tests we'll want to get working at some point.
What is the recommended method of providing these connection string values for nunit? Should we use environment variables, Power Shell, or something else?
________________________________
Support Staff 3 Posted by Feodor Fitsner on 16 Jul, 2014 06:40 AM
As far as I know there is not standard way of providing external data to NUnit tests. I would use environment variables for passing connection strings and other settings.
4 Posted by Vinney on 16 Jul, 2014 07:00 AM
Currently, we're running our integrated tests in Visual Studio, where they read the connection string from the app.config file. Are you suggesting that we can achieve this same functionality by adding environment variables? If so, does the variable just need to have the same name as the connection string name in the config? Di you have any examples or documentation for running integrated tests in AppVeyor?
Support Staff 5 Posted by Feodor Fitsner on 16 Jul, 2014 07:04 AM
OK, found it. You can use
testassembly.dll.config
with NUnit: http://www.nunit.org/index.php?p=configFiles&r=2.2.106 Posted by Vinney on 16 Jul, 2014 07:14 AM
Thanks. We'll try that on the morning. For me personally, this solution is not obvious. We expected that the config file would take precedence just as in VS. When it didn't, we were left wondering "what's wrong with AppVeyor?" Something for you to consider as you continue to develop this service. Thanks for the excellent support though!
Support Staff 7 Posted by Feodor Fitsner on 16 Jul, 2014 07:16 AM
I agree, it's not obvious. Where is that VS config located (I mean when you run tests from VS)?
8 Posted by Vinney on 16 Jul, 2014 07:21 AM
The config file I'm referring to is just an app[.transformProfile].config within the test project. I have never known of the nunit config file before you introduced it.
Support Staff 9 Posted by Feodor Fitsner on 16 Jul, 2014 07:24 AM
I see, thanks.
10 Posted by Vinney on 16 Jul, 2014 07:55 PM
We've been able to determine the cause of the issue. We're specifying a specific test assembly to run by entering the DLL name in the test assembly setting. However, since there are multiple projects in the solution, it appears that first instance of the specified DLL that AppVeyor is finding is in a bin folder from another project. This explains why the ConfigurationManager couldn't find the connection strings.
It seems that if we could just supply the path in the Test Assembly setting, we could ensure that the DLL which gets loaded into NUnit is indeed the DLL from the correct bin folder which would also contain the correct config file. Unfortunately, we haven't been able to find a filter parameter that works. The only filter parameter for which AppVeyor has been able to locate the tests is the actual DLL name with no path or wild card. Otherwise, it seems AppVeyor can't find the test assembly. According to the documentation, we've tried the following:
RioValleyChili.Services.Tests.dll (result: finds DLL but missing config file because DLL is located in the wrong directory)
*\RioValleyChili.Services.Tests\bin\Release\RioValleyChili.Services.Tests.dll (result: no tests found) C:\projects\rio-valley-chili-internal-src\RioValleyChili.Services.Tests\bin\Release\RioValleyChili.Services.Tests.dll (result: error invalid characters)
Any ideas?
Support Staff 11 Posted by Feodor Fitsner on 16 Jul, 2014 08:10 PM
The path should be relative. Try specifying
RioValleyChili.Services.Tests\bin\Release\RioValleyChili.Services.Tests.dll
.12 Posted by Vinney on 17 Jul, 2014 05:57 AM
We got this working. Here's an account of the issue should anyone else come by it in the future: http://vinneyk.azurewebsites.net/appveyor-null-connectionstrings-in.... Thanks for all your help, Feodor!
Support Staff 13 Posted by Feodor Fitsner on 17 Jul, 2014 06:27 AM
Great, thanks for the update and blogging about AppVeyor! ;)
Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 01:46 AM.