integration-testing

Stubbing authentication in request spec

烂漫一生 提交于 2019-12-17 04:17:05
问题 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

Spring Boot Integration test random free port

断了今生、忘了曾经 提交于 2019-12-14 00:37:23
问题 I am able to get Spring Boot integration to generate a random free port to launch itself on. But I also need a free port for Redis. @ContextConfiguration(classes = {MyApplication.class}, loader = SpringApplicationContextLoader.class) @WebIntegrationTest(randomPort = true, value = "server.port:0") @ActiveProfiles(profiles = {"local"}) public class SegmentSteps { private static final String HOST_TEMPLATE = "http://localhost:%s"; // Needs to be a random open port private static final int REDIS

executeUpdate() not updating on grails spock-integration testing

泪湿孤枕 提交于 2019-12-13 23:02:01
问题 hi i am new to grails testing. Willing to do integration test as below but problem is that executeUpdate() seems not updating the value How to do integration testing for executeUpdate('update query goes here') ?? Please help suggest me Sample code is given for problem demo. Thanks in advance. def "for given merchantTier Id update merchantTier value"(){ setup: def merchantTier = new MerchantTier( value:1.11).save(flush: true) //it saves merchantTier when:"when update with setProperty" testData

Rails 3 integration test mangles (model)_path(@instance) helper

旧城冷巷雨未停 提交于 2019-12-13 18:56:55
问题 I have a Doc class with the standard routes created by the scaffold generator. In the code, I use docs_path(@doc) # => /docs/7 which works fine. In my integration test I use: get docs_path(@doc) #=> /docs.7 which does not work at all fine. This is the same for other controllers that are using the standard routes for rails models. Using: get "/docs/7" in the integration test code works fine, but when I it tries to process a page using a '_path' or '_url' helper, then it mangles those in a

Slow startup on spring integration test. Cause? Can't disable RabbitMQ

二次信任 提交于 2019-12-13 16:56:11
问题 I'm struggling in a performance problem on startup with my integration tests. I'm trying to mock the messaging of the system. To do that, I basically use @MockBean on my gateway and use @EnableAutoConfiguration(exclude = {RabbitAutoConfiguration.class}) . Example: @RunWith(SpringRunner.class) @SpringBootTest(classes = MyApplication.class) @WebAppConfiguration @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) @ActiveProfiles("test") @EnableAutoConfiguration(exclude =

Maven running jetty on integration-test stage

馋奶兔 提交于 2019-12-13 13:35:47
问题 I use failsafe plugin. So when I type mvn failsafe:integration-test it stars my integration tests (which is great). But I want my jetty server starts on pre-integration stage then. What should I do? (I don't want launch mvn verify since it involves whole cycle running, but mvn failsafe:integration-test - it seems it's supposed to work that way) There are two plugins: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <!-- for starting jetty for

Why failsafe plugin requires both integration-test and verify goals?

南笙酒味 提交于 2019-12-13 13:12:24
问题 I have the next pom.xml <project> ... <plugin> <artifactId>maven-failsafe-plugin</artifactId> <version>2.6</version> <executions> <execution> <id>integration-test</id> <goals> <goal>integration-test</goal> <goal>verify</goal> </goals> <configuration> <argLine>${failsafeArgLine}</argLine> <includes> <include>**/dmg/*IT.java</include> </includes> <skipTests>${skipTests}</skipTests> </configuration> </execution> </executions> </plugin> ... </project> The problem is that when I'm taking off

Integration tests - what would you test for in this controller?

a 夏天 提交于 2019-12-13 10:29:23
问题 I'm applying NUnit integration tests on our controller endpoints in a .NET Web API 2 project whose models and controllers are generated via Entity code first from database . I'm having trouble thinking of what parts of the controller I should test. In the end, we'd just like to be able to automate "can a user with "x" role get this data?" Looking in the GET portion of this controller, what parts would you test and what's your reasoning? namespace api.Controllers.myNamespace { public class

IT code coverage with sonar

不羁的心 提交于 2019-12-13 08:05:51
问题 I have the following task at hand: -- find IT code coverage for a project Given situation: -- IT code resides in a repository separate to the actual production code -- Production code that the tests were created for reside in more than one git repository. -- all of the above uses maven and are written in Java. I have tried following different tutorial and blogs but couldnt find a simpler answer. Can anyone either point me towards the right resource or give me hints for a kick start? 回答1: I

How to keep service's metaClass from being overridden

时间秒杀一切 提交于 2019-12-13 07:43:33
问题 I'm trying to mock a call to an outside service in an integration test, the service is used in a grails webflow. The service isn't in flow or conversation scope, but is added via dependency injection see here. I've managed to figure out a way to override a service via replacing it's metaClass using ExpandoMetaClass. The changes only work when the test is ran alone, if another test that uses that same service is ran before this test, the metaClass changes are gone. Part that overrides the