Live Unit Testing doesn't copy over data file used by test - visual-studio-2017

I have a test that loads and processes a .json file. The file is part of the project and marked as "copy always" so that it's present in the build directory of the test, and I have veryfied that this does work on manual test run.
Live Unit Testing instead disregards this setting and fails the test as the file is not found. Is there any option other then disabling the test for live testing?

I solved this issue by moving the file I wanted to read in a subfolder of my unit test project, and then stopping and starting Live Unit Testing

Related

WebStorm run all dart unit tests

In WebStorm 11 I want to create a run configuration which runs all dart tests in my project.
However there is no option to do this in the "Dart Test" configuration template. The only options are:
Test Kind: All in file, Test group, single test
Test file: must point to a .dart file, otherwise I get "Dart file is not found"
VM Options (text input)
If I point WebStorm to a single test file this command gets executed in the test window:
C:\path\to\dart\bin\dart.exe --ignore-unrecognized-flags --checked --trace_service_pause_events file:\\\C:\path\to\dart\bin\snapshots\pub.dart.snapshot run test:test -r json C:/path/to/project/test/someclass_test.dart
I don't want to create a run configuration for every unit test class I write, there must be a better way.
Currently I prefer to navigate to the project directory and just run
pub run test:test
This runs all tests which live in files ending with _test.dart which is perfectly what I want. More info here: https://github.com/dart-lang/test#running-tests
Is there no such option in WebStorm for dart developers?
Accordingly to WEB-14747 ticket this functionality is already implemented for the next major version.
You can try latest EAP build of WebStorm v12 here.
I guess that's currently not supported.
The feature to run tests this way is quite new anyway.
If you think this feature is important, lease create a feature request in https://youtrack.jetbrains.com/issues/WEB

Connection strings not available from App.Config in Unit Tests run on TFS 2015

I'v some DB facing unit tests that take their connection string from an app.config file. I'm grabbing the strings thru ConfigurationManager class.
var conString = ConfigurationManager.ConnectionStrings["DB"].ConnectionString;
The tests run fine on dev machine but not on TFS. There is a null refernce error. If I jsut replace the connection string in unit test with a hard coded string - identical to that in app.config - then the test works. Oh yeah, and I've made sure that app.config is set to "copy to output folder".
Is there a known issue with TFS and ConfigurationManager?
pom
I recently ran into the same problem with TFS 2015 (on premises with update 2). We have multiple test projects that access a connection string from the app.config file however one particular project failed to access the connection string which caused our build to fail.
I altered the .csproj file to match other working test projects but this didn't provide any success, instead the following worked for me:
Copied the contents of the App.config to notepad
Deleted the App.config file from the project
Added a new Application Configuration File (App.config) to the project
Pasted the contents from notepad into the new App.confg file
Right click the App.config file and altered its properties:
Build Action: Content
Copy to output directory: Copy always
Upon check-in all unit tests within the project passed successfully.
It's an odd solution but it got our tests running.
Note: Deleting the App.config file was a necessary step. Changing the properties on the file (prior to deleting the file) didn't make a difference.
Update:
After applying the above solution I noticed all unit tests were running twice and after some investigation I discovered the entire issue was down to our build configuration: -
On our Visual Studio Build task we use the following parameter on our MS Build Arguments:
/p:OutDir=$(Build.StagingDirectory)
Our Visual Studio Test task was configured to look for Test Assembly in the following location:
**\$(BuildConfiguration)\*test*.dll;-:**\obj\**
Altering the Test Assembly location to the following fixed everything:
$(Build.StagingDirectory)\*test*.dll;-:**\_PublishedWebsites\**
No more issues with App.config files and unit tests ran once only.
Actually, I made another test project in my solution and added the app.config there again with the conn strings and now it works also on TFS. I don't know what the cause was but I'll leave the question here for possible reference and solution for others. Thank you.
My Test project is a separate project from the main project. Therefore it needs its own copy of App.config. Follow the steps in previous response to add new Application Configuration file and give it the same contents as in your main project.

Is Unit Test required for Xcode Bots Continuous Integration?

I don't have Unit Test script yet. I just want to see that the the integration itself is working and show 'Passed' results, is it possible without set of unit test? Currently, I always get Failed status on Summary of Results.
When creating the bot you can uncheck "Perform Test Action" and the bot will not run any unit tests. If you already created the bot you can go the bot under Log Navigator, select it and choose Edit Bot. You will be able to do the same thing there.
Although you haven't created unit tests yourself they are probably already in the project.
If you created your test project from one of the project templates, unit tests are included by default.
The unit tests included by default have a single test that always fails. Locate the unit test and comment out the XCTFail line in the [your project name]Tests.m file
//XCTFail(#"No implementation for \"%s\"", __PRETTY_FUNCTION__);

Need to deploy a file to the MSTest shadow directory that is used in TestInitialize()

I have a unit test that deploys a database using a .bak file in the TestInitialize method. I'm running this test from mstest using the dll (not from VS) so I need the .bak file to get copied to the shadow directory that mstest creates.
I don't want to add [DeploymentItem] attributes to every test method, I'm not even sure that would work since the TestInitialize is the method that is consuming this file.
Is there a tag I can put in the project that will guarentee that the .bak file will get copied to the shadow directory when running using MSTest on the test DLL?
Thanks
See Deployment Items: http://msdn.microsoft.com/en-us/library/ms182475(v=vs.80).aspx

TFS UnitTesting not deploying local copy assembly to test dir when on build server

I have an assembly that needs to be in the test output dir for my tests to run.
I have the assembly referenced as a local copy in the project but on the build server this gets ignored.
The two ways I have found to fix this are
Add a special attribute to test method that will make sure the file is there for each test.
[DeploymentItem("my assembly")]
This is not very practical as this assembly is required for almost every test in the assembly.
Add test run config file with special deployment section. I am using a TestContainer in my build scripts to run the tests I think that this may be the reason my included test run config does not get picked up and the assembly not copied. I would prefer to not have a vsmdi test list file as I am trying to run all tests and I feel this would be a violation of DRY.
Any suggestions on how I can get my tests running?
As my assembly was being dynamicly loaded the unit test framework was not copying it.
I added a explict refrence to it by calling typeof on one of the types in the assembly and all is fine.
Thanks Jerome Laban for your help with this one.