integration-testing

Prevent unit tests but allow integration tests in Maven

大憨熊 提交于 2019-11-26 11:46:25
问题 I\'ve a Maven build in which I use the SureFire plugin to run some unit tests, and the FailSafe plugin to run some integration tests. I would like a way to run just the FailSafe plugin\'s tests. It\'s not a good solution for me to add different profiles or anything in the pom, because it\'s a multimodule build and I don\'t want to have to edit every module\'s pom. There are skip.tests and maven.test.skip and skipTests which stop all tests, and skipITs, which stops only the failsafe plugin. So

Should one test internal implementation, or only test public behaviour?

放肆的年华 提交于 2019-11-26 11:45:17
Given software where ... The system consists of a few subsystems Each subsystem consists of a few components Each component is implemented using many classes ... I like to write automated tests of each subsystem or component. I don't write a test for each internal class of a component (except inasmuch as each class contributes to the component's public functionality and is therefore testable/tested from outside via the component's public API). When I refactor the implementation of a component (which I often do, as part of adding new functionality), I therefore don't need to alter any existing

What's the difference between unit tests and integration tests? [duplicate]

核能气质少年 提交于 2019-11-26 11:27:02
This question already has an answer here: What is the difference between integration and unit tests? 20 answers What's the difference between unit tests and integration tests? Are there different names for these tests? Like some people calling unit tests functional tests, etc? A unit test is a test written by the programmer to verify that a relatively small piece of code is doing what it is intended to do. They are narrow in scope, they should be easy to write and execute, and their effectiveness depends on what the programmer considers to be useful. The tests are intended for the use of the

How do I add a new sourceset to Gradle?

烈酒焚心 提交于 2019-11-26 08:58:59
问题 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? 回答1: 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

RSpec vs Cucumber (RSpec stories) [closed]

早过忘川 提交于 2019-11-26 07:52:09
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . When should I use specs for Rails application and when Cucumber (former rspec-stories)? I know how both work and actively use specs,

How to configure JPA for testing in Maven

人走茶凉 提交于 2019-11-26 06:05:40
问题 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

How to test a spring controller method by using MockMvc?

倾然丶 夕夏残阳落幕 提交于 2019-11-26 04:49:11
问题 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

Embedded MongoDB when running integration tests

陌路散爱 提交于 2019-11-26 04:33:36
问题 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

Before and After Suite execution hook in jUnit 4.x

帅比萌擦擦* 提交于 2019-11-26 03:27:53
问题 I\'m trying to preform setup and teardown for a set of integration tests, using jUnit 4.4 to execute the tests. The teardown needs to be run reliably. I\'m having other problems with TestNG, so I\'m looking to port back to jUnit. What hooks are available for execution before any tests are run and after all tests have completed? Note: we\'re using maven 2 for our build. I\'ve tried using maven\'s pre- & post-integration-test phases, but, if a test fails, maven stops and doesn\'t run post

Should one test internal implementation, or only test public behaviour?

旧时模样 提交于 2019-11-26 02:35:31
问题 Given software where ... The system consists of a few subsystems Each subsystem consists of a few components Each component is implemented using many classes ... I like to write automated tests of each subsystem or component. I don\'t write a test for each internal class of a component (except inasmuch as each class contributes to the component\'s public functionality and is therefore testable/tested from outside via the component\'s public API). When I refactor the implementation of a