What Im trying to achieve is to write UI tests for my MVC4 web application using Watin. Now I create a Browser object and open on URL localhost:xxxxx.
Problem is that the code running on localhost:xxxx using IIS Express is using production code which I dont want to be doing during test. In test I want for instance my IAuth and IDataProvider implementations to behave differently.
How do you UI test on a mocked instance of your application?
Ideas? :)
Solution was to make a bat file which runs a msbuild command which deploy to my local IIS. This works like a charm.
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe C:\Source\...\ProjectName.csproj /p:DeployOnBuild=true /p:PublishProfile="UnitTest" /p:Platform="Any CPU" /p:OutputPath="C:\inetpub\web" /p:VisualStudioVersion=11.0
Related
Consider a Visual Studio 2017 solution with 3 projects:
UWPApp - Universal Windows App
UWPAppTest - Universal Windows App Test (NuGet package: Microsoft.Azure.Mobile.Client)
MobileApp - Azure Mobile App web service (NuGet package: Microsoft.Azure.Mobile.Server)
I'd like to create a unit test in my UWPAppTest project, that calls my web service, running locally in my MobleApp web service project.
This requires me to somehow configure Visual Studio to launch the MobileApp project (selecting "don't open a page"). And at the same time, click "Debug Selected Test" in my test explorer. Or, somehow automatically launch the MobileApp in debug mode, when I debug a unit test.
This doesn't look like a supported scenario, and if not, what would be the next best workaround to be able to run a UWP test project, with tests calling a local web service?
Thanks
-John
This is something that Azure Mobile Apps has had to deal with as well. We use end-to-end test scenarios with a mobile backend hosted in the cloud. The test run will clear the contents of the database prior to each run, thus ensuring the appropriate unit testing. The biggest thing here is dealing with state.
In a local debug version, you will want to set the URI passed into the MobileServicesClient to your localhost, but things should not be any different. Just ensure you are fixing the starting point and ending point of your database for each test.
Is there a way to run unit test for a WebGL (GLGE) webapp in a headless browser?
I'd like to run the tests on a jenkins server, so the tests must run on a headless (phantom.js) brower.
Anybody already tried that?
Cheers
As of 2020 using puppeteer is probably the easiest way to use a headless browser that supports WebGL.
You can also use Chromium in headless mode directly
Right now this is my workflow to write tests for a website:
Record using Selenium IDE plugin in Firefox
Export Test Case As >> PHP (PHP Unit)
Run the tests on a Windows machine that has PHPUnit installed as well as the Selenium extension for it using this command:
phpunit --verbose --log-junit some\path\result.xml some\path\test.php
What this command does is runs the test and saves the output (assertions and failures) in a log file called result.xml. And all has been good.
But now I have run into a need to test a part of the site that involves flash and I am using an application called Arthropod to capture the requests and responses coming to and from the flash component on the site.
Is there any way I can get selenium to to capture the text that appears on this program's interface?
I believe Arthropod is an AIR application. If it is associated with the browser you may try using seleniumForAir for your testing.
You may like to have a look here.
I have a maven project.
I want to test (spring) controller class and also wrote a test class.To successfully run this test class,I want the web app to be deployed in the (jetty )server.
How I can achieve this, when I execute maven clean install.project is
built->deployed to server->start server->run test->stop server
I have been looking at jetty plugin and cargo plugin but still finding it difficult to do what I want.
If you want to unit test your spring controllers, you do not need to have your web application deployed to jetty. Spring framework has testing support as documented here.
There are many examples in the web. You can also refer to the test classes here which uses testNG.
If you do want to run tests in jetty, then refer to these instructions. Essentially you would bind the jetty start and stop to pre-integration-test and post-integration-test phases.
Is there a way to test a Web Service using VS2010 like it's used to test a web site?
For a web site I can create a set of WebTestRequest objects that emulate the loading and the parsing of a web page from the test and then, implementing the GetRequestEnumerator I can yield results to the load test so that the execution time and payload of any single page could be evaluated by the test runner and published in my test run reports.
I would like to do the same for a test using web service call so that each time I call the web service (there is some logic in calling it, like logging in, getting a security token and pass a proper formatted XML document to the web service method) I can yield the result to my test runner and evaluate it.
Is there a way to do it or do I need to implement a specific class inheriting from the WebTestItem abstract class?
Regards
Massimo
Yes, it is possible to test Web Services using Web Performance Tests in Visual Studio 2010 Ultimate.
Here's a couple of useful links:
How to: Create a Web Service test (MSDN)
How to: Web Service Load Testing Using VSTS 2010 (Blog)
As a starting point, you can use a web proxy tool like Fiddler to intercept the HTTP requests made to the Web Services, copy the contents of the SOAP envelopes in the Web Performance Tests and then tweak them accordingly based on the test scenario you want to simulate.
This doesn't quite answer your question as it's a 3rd party tool, but SOAP UI is a great piece of (free) software for load testing web services, whether your own or someone else's. You can run individual requests, or do a bunch of different load tests.
We've used it for one service that uses credentials, so I'm sure it will work fine for your scenario.