integration-testing

How to have Django test case and Selenium server use same database?

删除回忆录丶 提交于 2019-12-04 18:01:32
问题 I have a Django (v1.4, using Postgresql) project which I've written a bunch of working unittests for. These use FactoryBoy to generate most of their data. I'm now starting to write some integration tests using LiveServerTestCase with Selenium. I've just realised that my tests and the live test server use different databases. Which means that data created by factories in my tests aren't available to Selenium. I'm not sure of the best way to progress. I think I could use fixtures to supply data

How to prevent NestedServletException when testing Spring endpoints?

六月ゝ 毕业季﹏ 提交于 2019-12-04 17:43:26
问题 I am trying to test the security configuration of some of my endpoints which are secured with @PreAuthorize(#oauth2.hasScope('scope') . When accessing such an endpoint via Postman with a access token that does not have the required scope, the following is returned with HTTP status code 403 (forbidden): { "error": "insufficient_scope", "error_description": "Insufficient scope for this resource", "scope": "scope" } Which is the expected behaviour that I want. When trying to test this

Spring MockMVC inject mockHttpServletRequest when not in method signature

ぐ巨炮叔叔 提交于 2019-12-04 16:42:05
问题 Given I have inherited some Spring MVC controller code with signature @RequestMapping(value = "/upload", method = RequestMethod.POST) public ModelAndView upload(HttpServletRequest request, HttpServletResponse response) { String remoteAddress = request.getRemotedAddr(); auditService.logAddress(remoteAddress); // do work... return mav; } and I have a Spring MockMvc test that performs the test public void someTest() { mockMvc().perform(fileUpload("/upload").file(FileFactory.stringContent("myFile

How to obtain JNDI data source for JPA/JTA DAO integration test?

别等时光非礼了梦想. 提交于 2019-12-04 16:06:58
I have a JPA application that has specified JTA transactions in persistence.xml. For whatever reason, I have found that when using JTA, you MUST specify a JNDI data source within persistence.xml as well. This is fine, unless you are trying to go integration testing outside a container and JNDI is not available. My questions are: a) is there anyway to inject a jdbc datasource into my JTA transaction manager? b) if not, how do a handle a JNDI lookup during integration testing? Edit: The error I get when firing up the integration test is: Caused by: org.springframework......

testing Angular async services with Jasmine

随声附和 提交于 2019-12-04 15:31:50
I am trying to test a real http call with Jasmine (integration test), but when i call a method that uses $http.get, it times out and the server never gets called. I know that I am supposed to inject the implementation of $http but not sure where that should happen. searchSvc app.service('searchSvc', ['$http', '$q', searchSvc]); function searchSvc($http, $q) { return { search: function(text) { console.log('svc.search called with ', text); // this does get called return $q.when($http.get('/search/' + text)); } }; } searchSpec describe("searchTest", function() { var ctrl, svc, $http; beforeEach

How to use the Embedded PostgreSQL Server Java component as a separate service?

蓝咒 提交于 2019-12-04 14:11:12
问题 I am trying to create a comprehensive integration test suite for a RESTful (Services) Java-based application that runs in Tomcat(7.x) and depends on an Postgresql (9.x) instance. Further, I would like to be able to run this suite as a self-contained process, exclusively from maven 3.x, if possible, by using the maven failsafe plugin. That way, the tests can be run across the 3 major platforms (Mac OSX, Linux & Windows). From what I have learned, I believe that the key to making this happen is

Unreliable/Flakey Capybara/AngularJS Integration Tests With Timing Issues

放肆的年华 提交于 2019-12-04 14:05:54
问题 How do I make these tests reliably pass? Currently these tests are flakey. Sometimes they pass. Sometimes they fail. Below is the setup, code and output demonstrating this issue. Suggestions to overcome this issue will be greatly appreciated and I am sure will help many others, so please comment! Test Code Environment Rails 3.2 RSpec 2.x Capybara Poltergeist PhantomJS AngularJS Google Chrome Version 47.0.2526.106 (64-bit) Testing Gems from Gemfile.lock capybara (2.1.0) database_cleaner (0.7.1

Do you need to do unit and integration testing if you already do functional testing? [closed]

不羁的心 提交于 2019-12-04 13:33:36
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . People at my company see unit testing as a lot of extra work, that offers fewer benefits than existing functional tests. Are unit and integration tests worth it? Note a large existing codebase that wasn't designed with testing in mind. 回答1: (I'm assuming that you're using

Using $injector in AngularJS when integration testing (without using ngMock)

◇◆丶佛笑我妖孽 提交于 2019-12-04 12:47:36
I'm needing to setup some integration tests in AngularJS using Karma/Jasmine but having trouble, because when not using ngMock (since I want to hit the actual $http endpoints), there are no module or inject methods. So how do I inject services into my tests? I've tried angular.injector.invoke(...) but can't get it working, always comes back with an error like Unknown provider: AuthServiceProvider <- AuthService . Thoughts? Try this 'use strict'; describe('Login User', function () { var app, LoginService; beforeEach(module('app')) ; beforeEach(inject(function(_LoginService_) { LoginService =

How can I assert that no route matches in a Rails integration test?

依然范特西╮ 提交于 2019-12-04 12:12:19
问题 I have a Rails 3 integration test which tests my routes. It contains tests such as: assert_routing( "/#{@category.url.path}/#{@foo.url.path}", { :controller => 'foo', :action => 'show', :category => @category.to_param, :foo => @foo.to_param } ) I would also like to test a case where no routes should match. Obviously, testing generation has no meaning in this case, so I just need the inverse of assert_recognizes. I'd like to be able to do something like this: assert_not_recognized('