functional-testing

Rails functional test: sending URL query parameters in POST request

别等时光非礼了梦想. 提交于 2019-12-21 09:14:15
问题 I'm sending a POST request in a Rails functional test like this: post :create, collection: { name: 'New Collection' } collection gets sent as JSON-encoded form data, as expected. What I can't figure out is how to add a query to the URL. The documentation says that I can access the request object and modify it before it gets sent. So I tried this: @request.GET[:api_key] = 'my key' post :create, collection: { name: 'New Collection' } But, :api_key never appears in the request.GET hash on the

Testing File uploads in Symfony2

妖精的绣舞 提交于 2019-12-21 07:06:09
问题 In the Symfony2 documentation it gives the simple example of: $client->request('POST', '/submit', array('name' => 'Fabien'), array('photo' => '/path/to/photo')); To simulate a file upload. However in all my tests I am getting nothing in the $request object in the app and nothing in the $_FILES array. Here is a simple WebTestCase which is failing. It is self contained and tests the request that the $client constructs based on the parameters you pass in. It's not testing the app. class

Testing sub-flows in Mule

社会主义新天地 提交于 2019-12-21 04:49:18
问题 I have started writing test cases to my Mule project. I have written the functional test case for my Main Flows as follows. public void testMainFlow_1() throws Exception{ MuleClient client = muleContext.getClient(); MuleMessage result = client.send(helloServiceAddress, fileAsString("SamplePayloads/input_Request.xml"), properties); assertNotNull("Null Result", result); assertEquals(result.getPayloadAsString(), fileAsString("SampleResponses/sampleResponse.xml")); } But how can I test my sub

How to do concurrent modification testing for grails application

可紊 提交于 2019-12-21 04:08:36
问题 I'd like to run tests that simulate users modifying certain data at the same time for a grails application. Are there any plug-ins / tools / mechanisms I can use to do this efficiently? They don't have to be grails specific. It should be possible to fire multiple actions in parallel. I'd prefer to run the tests on functional level (so far I'm using Selenium for other tests) to see the results from the user perspective. Of course this can be done in addition to integration testing if you'd

Symfony2 Functional Testing - Click on elements with jQuery interaction

与世无争的帅哥 提交于 2019-12-20 20:41:07
问题 I'm doing some functional tests for an application done with Symfony2 (2.1) and I'm stuck with a problem. I have some parts of the website that load when the user clicks a link or other element, but these actions are performed using jQuery and $.post calls. How can I get the Symfony2 crawler to do these calls? When I do something like this: $link = $crawler->filter('ul.line_menu a')->eq(1)->link(); $crawler = $client->click($link); The crawler gets the "href" of the "a" element and launches

Sinatra, Rack::Test, and Conditional GET requests

巧了我就是萌 提交于 2019-12-20 17:28:37
问题 I've got a Sinatra 1.2.0 app that is doing Last-Modified validation caching with Rack::Cache. Things are working great-- I call last_modified in my route body and if the cache has an up-to-date copy, the rest of the execution halts, my app responds to the cache with 304 Not Modified, and the cache serves the cached page without having to generate a new one. My issue is in trying to write tests for this process. Using Rack::Test and Minitest::Spec, I'm simulating the cache's conditional Get

Making functional tests in Rails with Devise

送分小仙女□ 提交于 2019-12-20 09:17:14
问题 After 3 years of procrastination today is the day that I start testing my Rails apps. My first step is to fix the failing tests in my Rails 3 beta4 app. My last 3 failing tests have to do with the devise gem and its authenticate_user! method in a before_filter at the top of my controller. You'd earn great karma by helping me out with this since it will enable me to use the TDD methodology from now on. Here is the error that troubles me: 1) Error: test_should_get_accepted

How to cut a long ScalaTest spec to pieces

*爱你&永不变心* 提交于 2019-12-20 04:48:27
问题 I'm testing a REST API, and the code goes like this: Setting up stuff, populating a database using PUSH calls Testing API a Testing API b ... The code is currently in one rather huge FlatSpec : class RestAPITest extends FlatSpec with Matchers with ScalatestRouteTest with SprayJsonSupport I would like to chop the "Testing API a/b/..." parts out, to have the code more manageable. Trying to do that seems like a no-no: what's the type of it - how to pass that on, etc. etc. So, what's the

Failed asserting the HTTP status code is 200 not 500

旧时模样 提交于 2019-12-20 02:29:32
问题 I'm trying to functional test the HTTP status code for a certain request is 200 not 500 . I'm using Symfony2, and here's the code: public function testIndex() { $client = static::createClient(); $crawler = $client->request('GET', "/"); $this->assertEquals('Ibw\JobeetBundle\Controller\JobController::indexAction', $client->getRequest()->attributes->get('_controller')); $this->assertEquals(200 , $client->getResponse()->getStatusCode()); $this->assertEquals(0, $crawler->filter('.jobs td.position

ServiceStack AppHostHttpListenerBase Unable to connect to the remote server

ぃ、小莉子 提交于 2019-12-20 01:08:37
问题 I'm working through some Functional Tests on my app, and I think I'm getting pretty close. My problem is that when I run my first test, I get the error. unable to connect to the remote server. Expected: OK But was: 0 I can confirm that if I put a breakpoint on the Assert, and then try to hit the BaseUrl in my browser, it is not found. Here's my test. [Test] public void MyTestTest () { var client = new RestClient( ServiceTestAppHostBase.BaseUrl ); // client.Authenticator = new