The legacy code uses a service reference called DesignTime2ServiceReference and it connects to endpoint http://localhost:8733/Design_Time_Addresses/XXX
I have added "/client:WcfTestClient.exe" into [project > Properties > Debug > Start Options > Command Line Arguments]. When I do that the tests passes if they are debugged. But if I simply run them, they still fail.
Of cause I've tried to use the same trick for [project > Properties > Release > ...] but that does not work.
I am currently using VS 2022.
I have no idea how that was supposed to work once - and more pressingly - how to make it work now.
The tests are integration tests, implemented in MS Test and calling this code direcly:
using (var client = new DesignTime2ServiceReference.XXXClient())
Related
Running Visual Studio for Mac 17.4.2 (build 17)
I have a unit test that uses core WCF to call a web service at: https://www.dataaccess.com/webservicesserver/NumberConversion.wso
This works fine when I run the test if I have the ProxyMan app running. However, without ProxyMan I get a timeout after one minute.
In order to generate the wcf proxy class, I ran the following against my unit test project:
dotnet tool install --global dotnet-svcutil
dotnet-svcutil --roll-forward LatestMajor https://www.dataaccess.com/webservicesserver/NumberConversion.wso?WSDL
This generated a large reference.cs file - which I've copied here
My unit test that calls into this can be seen below:
[Fact]
public async Task CanConvertNumber()
{
var client = new NumberConversionSoapTypeClient(NumberConversionSoapTypeClient.EndpointConfiguration.NumberConversionSoap,
"https://www.dataaccess.com/webservicesserver/NumberConversion.wso");
var response = await client.NumberToWordsAsync(46);
Trace.WriteLine($"The response is: {response.Body.NumberToWordsResult}");
response.Body.Should().Equals("Forty Six");
}
I have now created a simple console app to reproduce what I have in the unit test. The code for this can be found at: https://github.com/RobBowman/core-wcf-client
Any ideas why it could be dependent on proxyman? It seems as if core wcf code is routing to localhost for some reason.
Thanks,
Rob.
I have a project under appveyor. Running the build script fails when testing begin with the following message:
EXEC : error : Could not find file: C:\projects\Projname\test\Projname.Tests\bin\Release\xunit.dll
I'm invoking the test runner from the build script using:
xunit.console.clr4 test/Projname.Tests/bin/Release/Projname.Tests.dll /appveyor
xunit.console is working fine locally on my machine and without looking for xunit.dll. Why is this happening in appveyor?
I have no idea what's causing the problem, so I followed what appveyor really does when it automatically discovers and runs tests (as opposed to what it instructs us to do in the docs).
My script that runs on the CI is now this:
%xunit20%\xunit.console.x86 path\to\test.dll -appveyor
I found that one of my tests that passes in VS2013 is failing in VS2015, the test calls a service that includes among other things a call to Console.Clear();
to find out whats going on I made a simple unit test
[TestMethod]
public void ExampleTest()
{
Console.Clear();
}
This test passes in visual studio 2013 but in 2015 I get the following error:
Test Name: ExampleTest
Test FullName: solution.Common.Test.CacheManagerTest.ExampleTest
Test Source: C:\solution.Common.Test\CacheManagerTest.cs : line 34
Test Outcome: Failed
Test Duration: 0:00:00.3015003
Result StackTrace: at System.IO.__Error.WinIOError(Int32 errorCode,
String maybeFullPath) at System.Console.GetBufferInfo(Boolean
throwOnNoConsole, Boolean& succeeded) at System.Console.Clear()
at sol.Common.Test.CacheManagerTest.ExampleTest() in
C:\solution.Common.Test\CacheManagerTest.cs:line 35 Result Message:
Test method Alexandria.Common.Test.CacheManagerTest.ExampleTest threw
exception: System.IO.IOException: The handle is invalid.
I do understand that it is bad design for my service to fail if it is not called by a console. The reason I am asking this question is to understand why this is failing in the new version of Visual Studio. Is this the intended behavior? What changed?
I did not see anything obvious in the change log that would seem related to this.
Edit: I am calling the Console.clear from the following dll
Microsoft\Framework.NETFramework\v4.5.1\mscorlib.dll
Edit 2:
picture of testproject properties in both visual studios
The changes in VS2015 are pretty visible, use the Test > Debug > All Tests to get insight. You can see that it now has a new test host process, its name is TE.ProcessHost.Managed.exe, stored in the C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow directory.
Previous versions of VS used a different host, vstest.executionengine.exe. One notable change in the new test host is that it is no longer a console mode program. Something you can see by running Dumpbin.exe /headers on the exe.
Another way to see the underlying problem is with Task Manager. Note how running a test in an older VS version causes a conhost.exe process to get added. This is the process that owns the console window for a console mode app. A problem I've seen before is that this process tends to leak, not terminating when the test completes. Adding ever more conhost.exe instances, at one point researching this problem I had 12 of them running. Presumably the changes in VS2015 were meant to address that problem.
Technically you can configure the unit test with a .runsettings file and use the <ForcedLegacyMode> element to force the old test host process to be used. This however has no effect on the outcome of this test, looks like they addressed this in multiple ways.
That's a fair amount of guessing, I recommend you use connect.microsoft.com to file a feedback report. You can quote this Q+A for reference.
Meanwhile, you can consider a workaround. Do note that Console.Clear() is in general a trouble-maker, it will also fail in normal usage when the output of a console mode app is redirected. Very easy to do from a command line prompt with the > operator. Which is the ultimate reason it fails in a unit test. You'll want to make the code resilient so it can work properly both in production and in a unit test. Like this:
if (!Console.IsOutputRedirected) Console.Clear();
Which requires targeting .NET 4.5 or higher. You can use the code in this SO post if you need to target earlier versions.
I have been unable to get my CodedUI test project to run. The goal is to have it run on a separate machine (virtual machine). I've configured the test controller and agent on the VM. I've also set it to run as interactive process (details below). When I run my build it partially succeeds and the following test error is reported:
Error calling Initialization method for test class XXXX.CodedUI:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestException: To
run tests that interact with the desktop, you must set up the test
agent to run as an interactive process. For more information, see "How
to: Set Up Your Test Agent to Run Tests That Interact with the
Desktop" (http://go.microsoft.com/fwlink/?LinkId=255012)
I've performed the following steps:
I've installed a Test Controller and Test Agent to VM (separate from TFS server)
My Test Controller was set "Register test controller with Team Project Collection". I've removed the checkbox! This caused a different error when running my build so I removed the checkbox.
My Test Agent is set to the test controller - set to interactive process - screen saver disabled
I have added a Test settings file to my solution.
Test Execution Method: Remote Execution
Controller shows my controller
Manage Test Controllers shows my Test Agent as Ready!!
Resources I used:
http://msdn.microsoft.com/en-us/library/ee291332.aspx
http://msdn.microsoft.com/en-us/library/dd695837.aspx
After performing all the steps I'm still getting the same error. What could the problem be? My test settings seems to correctly point to the test controller. The test controller and agent seems to be configured correctly. Do I need to use Lab Management to have these tests run on a VM?
Thanks!
You need to configure a Standard Environment in Lab management so that tfs knows where you are sending the tests.
http://nakedalm.com/standard-environments-for-automated-deployment-and-testing/
Should only take you a few minutes to setup.
Alternative set up is the following (without Lab Management environment):
1) do NOT register test controller with a Team Project Collection
2) have your agent set up to interact with desktop
3) in your solution - create testsettings file for the coded UI test run, point it to your test controller
4) in your build definition - set up automated tests to use this newly created test settings file
I am trying to run coded UI test in MTM when build is triggering in TFS2015. set up is done with test agent and test controller and created LabEnvironment. When I trigger build then build is success but test case is not executed showing below error .Enabled interactive window in test agent.
MTM, Test agent , test controller, TFS installed in my same machine (Local machine)
I'm purposely running test cases during the build. This is going to be a build that kicks off my CodedUI tests.
Error calling Initialization method for test class CodedUITestProject.CodedUITest1: Microsoft.VisualStudio.TestTools.UITest.Extension.UITestException: To run tests that interact with the desktop, you must set up the test agent to run as an interactive process. For more information, see "How to: Set Up Your Test Agent to Run Tests That Interact with the Desktop" (http://go.microsoft.com/fwlink/?LinkId=255012) If you are running the tests as part of your team build, you must also set up the build age
I'm currently working on a Windows Store Application (Windows 8) for a class and I'm having problems getting my NUnit tests to run.
My Solution/Project setup looks like the following:
TheMetroApp.sln
SQLite-net.csproj - Class Library (Windows Store Apps). Files are pulled from NuGet.
DataModel.csproj - Class Library (Windows Store Apps)
UnitTests.csproj - Unit Test Library (Windows Store Apps). NUnit framework is pulled from NuGet.
TheMetroApp.csproj - A project file which was pulled from one of the Windows SDK examples.
Misc. Dependencies and Utilities
Windows 8 Pro RTM/Visual Studio 2012 RTM
ReSharper 7
NUnit 2.6.1
SQLite (Set up per the instructions here)
UnitTests is dependent upon and references DataModel. DataModel is dependent upon and references SQLite-net. The only thing I have added to the UnitTests project is a single class containing some stub NUnit unit tests. As far as I can tell, these are set up correctly:
[TestFixture]
public class TaskSourceTests
{
#region Private Class Members
private ITaskSource _taskSource;
private String _dbPath;
#endregion
#region Testing Infrastructure
[SetUp]
public void SetUp()
{
// This part makes NUnit/ReSharper have problems.
_dbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "UnitTestDatabase.sqlite");
}
#endregion
#region Misc. CRUD stuff
[Test]
public void CreateTaskTest()
{
// Save the task.
Task task = new Task( "Some Task", "lol.", DateTime.Now, false );
_taskSource.Save( task );
// Confirm that it is in the task db.
using( SQLiteConnection db = new SQLiteConnection( _dbPath ) )
{
const String query = "SELECT * FROM Task WHERE Id = ?";
IList<Task> results = db.Query<Task>( query, task.Id );
Assert.True( results.Contains( task ) );
}
}
// ...and so on [but with stubs that are basically Assert.Fail( "" )].
#endregion
}
TheMetroApp is one of the Windows 8 SDK sample projects, but with some custom XAML forms thrown in. I'm not having any problems with this project.
My issue is that none of the Unit Test runners that I have tried to use are working.
When I try to use the official NUnit x86 Test runner (version 2.6.1), my tests fail due to certificate related issues (see here):
UnitTests.TaskSourceTests.CreateTaskTest:
SetUp : System.InvalidOperationException : The process has no package identity. (Exception from HRESULT: 0x80073D54)
ReSharper's NUnit test runner fails for the exact same reason. Unfortunately, it doesn't look like there is currently a workaround for that.
I have also tried using the test runner built into Visual Studio 2012 (through the NUnit Visual Studio Test Adapter). When I try to run my tests using "Run All", I get the following output:
------ Run test started ------
Updating the layout...
Checking whether required frameworks are installed...
Registering the application to run from layout...
Deployment complete. Full package name: "GibberishAndStuff"
No test is available in C:\Projects\project-name\ProjectName\UnitTests\bin\Debug\UnitTests.dll. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.
========== Run test finished: 0 run (0:00:09.4873768) ==========
Something strange I have noticed is that if I select a specific test in the Test Explorer and tell it to run, I get a slightly different error message:
Could not find test executor with URI 'executor://nunittestexecutor/'. Make sure that the test executor is installed and supports .net runtime version 4.0.30319.18010.
This is kind of perplexing because I have the NUnit Test Adapter installed. I'm not seeing anything similar to my issue on the launchpad page for the test adapter.
I'm not really sure where I should proceed from here. If this doesn't work I don't mind reworking my project to use xUnit.net, Microsoft's unit testing framework or something else. It would be pretty awesome if I could get NUnit working though.
Thanks!
I have a Windows 7 Phone app which had the same issue that you have. My solution was to create a separate "linked" project which compiles the code using the standard .net libraries. The linked project will have no issues with unit test / NUnit.
See the following for more information:
http://msdn.microsoft.com/en-us/library/ff921109(v=pandp.40).aspx
http://visualstudiogallery.msdn.microsoft.com/5e730577-d11c-4f2e-8e2b-cbb87f76c044/
I've ported the app to Windows 8 and have no problems running my test cases.
I've just hit the same error message while creating unit tests for an Universal App (W81 + WP81). The only solution here was to stop using NUnit and use MSTest only.