integration-testing

Mocking for integration tests

这一生的挚爱 提交于 2019-12-20 08:25:38
问题 How does one mock the many dependencies needed for integration tests? I use Mockito for my 'pure' unit tests. 'Pure' in this case means testing a single class, mocking all of it's dependencies. Beautiful. Now come integration tests. Let's say in this case an integration test will test something like this: Message is put on a queue Message is 'processed' Response message is put on a response queue Let's also say that the processing that happens in step 2 is serious stuff. It relies on lots of

How to make Capybara check for visibility after some JS has run?

懵懂的女人 提交于 2019-12-20 08:13:23
问题 After loading a page I have code that runs and hides and shows various items based on data returned by an xhr. My integration test looks something like this: it "should not show the blah" do page.find('#blah').visible?.should be_true end When I manually go to the page in the context this test runs, #blah is not visible as I expect. I suspect that Capybara is looking at the initial state of the page (invisible in this case), evaluating the state of the DOM and failing the test before the JS

How to make Capybara check for visibility after some JS has run?

痞子三分冷 提交于 2019-12-20 08:12:35
问题 After loading a page I have code that runs and hides and shows various items based on data returned by an xhr. My integration test looks something like this: it "should not show the blah" do page.find('#blah').visible?.should be_true end When I manually go to the page in the context this test runs, #blah is not visible as I expect. I suspect that Capybara is looking at the initial state of the page (invisible in this case), evaluating the state of the DOM and failing the test before the JS

meta replacing same method in two different tests not working?

妖精的绣舞 提交于 2019-12-20 06:17:01
问题 Test controller is as follows def justTest(){ def res = paymentService.justTest() [status: res.status] } Test service method is as follows def justTest(){ } Now the two test cases are as follows. Payment service method justTest was modified in both cases to return two different values. @Test void test1(){ PaymentService.metaClass.justTest = {['status': true]} def res = controller.justTest() assertEquals(res.status, true) GroovySystem.metaClassRegistry.removeMetaClass(PaymentService.class) }

Writing tests for an Android app that logs into Facebook

核能气质少年 提交于 2019-12-20 03:11:28
问题 My Android app uses FacebookSDK for login. It's the first screen, and you can't do anything unless you login. I want to write some Espresso tests to be ran on Greenhouse Continuous integration server. I searched and I found FBSDKTestUsersManager on iOS, but nothing similar on Android. What I plan to do is create a flavor of test and when that flavor is selected instead of a normal Facebook login button, I'd display a button that gets a test access token for the user, then brings them to the

Using autofixture in my data integration tests to create proxies

偶尔善良 提交于 2019-12-19 19:54:38
问题 I'm trying to write a suite of database integration tests for my domain which uses Entity Framework. I would prefer to autofixture objects in some scenarios. My ideal syntax would be something like [TestMethod] public void AutofixtureMyEntityEntity() { var fixture = new Fixture(); fixture.Customize<MyEntity>( c => c.FromFactory<MyDbContext>(ctx => ctx.Set<MyEntity>().Create())); using (var context = new MyDbContext()) { fixture.Inject(context); var entity = fixture.CreateAnonymous<MyEntity>()

@TestPropertySource is not loading properties

冷暖自知 提交于 2019-12-19 09:06:35
问题 I'm writing integration test for my spring boot application but when I try to override some properties using @TestPropertySource, it's loading the property file defined in the context xml but it's not overriding the properties defined in the annotation. @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = {DefaultApp.class, MessageITCase.Config.class}) @WebAppConfiguration @TestPropertySource(properties = {"spring.profiles.active=hornetq", "test.url=http://www

@TestPropertySource is not loading properties

好久不见. 提交于 2019-12-19 09:06:08
问题 I'm writing integration test for my spring boot application but when I try to override some properties using @TestPropertySource, it's loading the property file defined in the context xml but it's not overriding the properties defined in the annotation. @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = {DefaultApp.class, MessageITCase.Config.class}) @WebAppConfiguration @TestPropertySource(properties = {"spring.profiles.active=hornetq", "test.url=http://www

Spring Boot's TestRestTemplate with HATEOAS PagedResources

半世苍凉 提交于 2019-12-19 09:05:30
问题 I'm trying to use the TestRestTemplate in my Spring Boot Application's Integration-Test, to make a request to a Spring Data REST Repository. The response in the browser has the form: { "links": [ { "rel": "self", "href": "http://localhost:8080/apiv1/data/users" }, { "rel": "profile", "href": "http://localhost:8080/apiv1/data/profile/users" }, { "rel": "search", "href": "http://localhost:8080/apiv1/data/users/search" } ], "content": [ { "username": "admin", "enabled": true, "firstName": null,

How do I get my Spring-JUnit test to think its running in a GenericApplicationContext?

99封情书 提交于 2019-12-19 05:47:32
问题 I’m using Spring 3.2.6.RELEASE , JUnit 4.11 , and DWR 3.0.0-rc2 . My question is, when running a Spring-JUnit integration test, how can I simulate things being run in a org.springframework.context.support.GenericApplicationContext ? I tried this: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration({ "classpath:test-context.xml", "classpath:dwr-context.xml" }) @WebAppConfiguration public class MyServiceIT {} in which my “dwr-context.xml” file is set to be <?xml version="1.0" encoding