integration-testing

How do I add a new sourceset to Gradle?

a 夏天 提交于 2019-11-26 19:36:22
I want to add integration tests to my Gradle build (Version 1.0). They should run separately from my normal tests because they require a webapp to be deployed to localhost (they test that webapp). The tests should be able to use classes defined in my main source set. How do I make this happen? This took me a while to figure out and the online resources weren't great. So I wanted to document my solution. This is a simple gradle build script that has an intTest source set in addition to the main and test source sets: apply plugin: "java" sourceSets { // Note that just declaring this sourceset

Stubbing authentication in request spec

安稳与你 提交于 2019-11-26 18:18:26
When writing a request spec, how do you set sessions and/or stub controller methods? I'm trying to stub out authentication in my integration tests - rspec/requests Here's an example of a test require File.dirname(__FILE__) + '/../spec_helper' require File.dirname(__FILE__) + '/authentication_helpers' describe "Messages" do include AuthenticationHelpers describe "GET admin/messages" do before(:each) do @current_user = Factory :super_admin login(@current_user) end it "displays received messages" do sender = Factory :jonas direct_message = Message.new(:sender_id => sender.id, :subject => "Message

Problem using SQLite :memory: with NHibernate

£可爱£侵袭症+ 提交于 2019-11-26 17:58:13
问题 I use NHibernate for my dataacess, and for awhile not I've been using SQLite for local integration tests. I've been using a file, but I thought I would out the :memory: option. When I fire up any of the integration tests, the database seems to be created (NHibernate spits out the table creation sql) but interfacting with the database causes an error. Has anyone every gotten NHibernate working with an in memory database? Is it even possible? The connection string I'm using is this: Data Source

Capybara with subdomains - default_host

匆匆过客 提交于 2019-11-26 17:36:36
问题 I have an app that uses subdomains to switch databases (multi-tenancy). I'm trying to use Capybara for integration testing, and it really relies a lot on subdomains. My understanding was that setting Capybara.default_host= to something would make all my requests come from this host. This doesn't seem to be the case. In this post, the author recommends just visiting the explicit url with a host, but this becomes a bit annoying if I'm navigating all over the place. I'd like to just set the host

How to configure JPA for testing in Maven

99封情书 提交于 2019-11-26 17:07:48
Is there a way to set up a second persistence.xml file in a Maven project such that it is used for testing instead of the normal one that is used for deployment? I tried putting a persistence.xml into src/test/resources/META-INF, which gets copied into target/test-classes/META-INF, but it seems target/classes/META-INF (the copy from the src/main/resources) gets preferred, despite mvn -X test listing the classpath entries in the right order: [DEBUG] Test Classpath : [DEBUG] /home/uqpbecke/dev/NetBeansProjects/UserManager/target/test-classes [DEBUG] /home/uqpbecke/dev/NetBeansProjects

How to test a spring controller method by using MockMvc?

霸气de小男生 提交于 2019-11-26 16:34:37
I'm using spring 3.2.0 and junit 4 This is my controller method which I need to test @RequestMapping(value="Home") public ModelAndView returnHome(){ return new ModelAndView("Home"); } spring-servlet config is: <context:annotation-config/> <context:component-scan base-package="com.spring.poc" /> <mvc:annotation-driven /> <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value=".jsp" />

Embedded MongoDB when running integration tests

感情迁移 提交于 2019-11-26 15:42:12
My question is a variation of this one . Since my Java Web-app project requires a lot of read filters/queries and interfaces with tools like GridFS, I'm struggling to think of a sensible way to employ MongoDB in the way the above solution suggests. Therefore, I'm considering running an embedded instance of MongoDB alongside my integration tests. I'd like it to start up automatically (either for each test or the whole suite), flush the database for every test, and shut down at the end. These tests might be run on development machines as well as the CI server, so my solution will also need to be

How should I set up my integration tests to use a test database with Entity Framework?

纵然是瞬间 提交于 2019-11-26 15:21:26
问题 I am writing integration tests for an application and have not been able to find any best practices on how to set up a test database for my integration suite. I am working on an ASP.NET MVC4 application using Entity Framework code-first. I can confirm that the tests in my test project talk to the local development database on my machine by default. This is not ideal, as I want to have a fresh database every time I run the tests. How can I set up my test project so that my tests talk to a

How can I skip tests in maven install goal, while running them in maven test goal?

末鹿安然 提交于 2019-11-26 12:51:56
问题 I have a multi-module maven project with both integration and unit tests in the same folder (src/test/java). Integration tests are marked with @Category(IntegrationTest.class) . I want to end up with the following setup: If I run mvn install , I want all tests to compile, but I do not want to execute any. If I run mvn test , I want all tests to compile, but execute only unit tests. If I run mvn integration-test , I want to compile and execute all tests. The important point is, I want this

How to test a confirm dialog with Cucumber?

别来无恙 提交于 2019-11-26 12:15:41
问题 I am using Ruby on Rails with Cucumber and Capybara. How would I go about testing a simple confirm command (\"Are you sure?\")? Also, where could I find further documentation on this issue? 回答1: Seems like there's no way to do it in Capybara, unfortunately. But if you're running your tests with the Selenium driver (and probably other drivers that support JavaScript), you can hack it. Just before performing the action that would bring up the confirm dialog, override the confirm method to