integration-testing

capybara: page.should have_no_content doesn't work correctly for display:none element

隐身守侯 提交于 2019-11-27 18:11:53
问题 I would like to use page.should have_no_content to check if the page doesn't display the label to user, here what it is in HTML: <li id="account_input" style="display: none;"> <label for="account_name">My Account</label> ... </li> So when I use page.should have_no_content("My Account"), it returns false instead of true. 回答1: You could use this statement find('#account_input').should_not be_visible 回答2: I found a solution using: Then /^"([^\"]+)" should not be visible$/ do |text| paths = [ "//

How are integration tests written for interacting with external API?

断了今生、忘了曾经 提交于 2019-11-27 17:02:55
First up, where my knowledge is at: Unit Tests are those which test a small piece of code (single methods, mostly). Integration Tests are those which test the interaction between multiple areas of code (which hopefully already have their own Unit Tests). Sometimes, parts of the code under test requires other code to act in a particular way. This is where Mocks & Stubs come in. So, we mock/stub out a part of the code to perform very specifically. This allows our Integration Test to run predictably without side effects. All tests should be able to be run stand-alone without data sharing. If data

Integration test with IOptions<> in .NET Core

↘锁芯ラ 提交于 2019-11-27 16:30:40
问题 I pass IOption<T> to my CommandBus so I can get the settings from my ServiceBusSetting class. I want to do an integration test of my Bus. I do not want to resolve it just use new QueueCommandBus and need to pass IOptions to it. var services = new ServiceCollection().AddOptions(); services.Configure<ServiceBusAppSettings>(Configuration.GetSection("ServiceBus")); var options = services.BuildServiceProvider().GetService<IOptions<ServiceBusAppSettings>>(); ////Act var commandBus = new

Adding classpath to jetty running in maven integration-test

廉价感情. 提交于 2019-11-27 12:46:02
问题 I'm trying to set up integration tests for a Maven project that produces a war file. (As seen here http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin/.) However I the war file requires a bunch of .properties files on the classpath, that I don't want to bundle in the war. Is there a way (preferably through plugin configuration) to add a folder to the classpath used by jetty? I Googled this and found http://markmail.org/message/awtqrgxxttra3uxx but this, as far as I can tell, does not

How to apply integration tests (rather than unit tests) to a Flask RESTful API

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 12:17:34
问题 [As per https://stackoverflow.com/a/46369945/1021819, the title should refer to integration tests rather than unit tests] Suppose I'd like to test the following Flask API (from here): import flask import flask_restful app = flask.Flask(__name__) api = flask_restful.Api(app) class HelloWorld(flask_restful.Resource): def get(self): return {'hello': 'world'} api.add_resource(HelloWorld, '/') if __name__ == "__main__": app.run(debug=True) Having saved this as flaskapi.py and run it, in the same

TDD and ADO.NET Entity Framework

℡╲_俬逩灬. 提交于 2019-11-27 10:56:52
问题 I've been playing with ADO.NET Entity Framework lately, and I find that it suits my needs for a project I'm developing. I also find cool its non-invasive nature. After generating a data model from an existing database you are faced with the task of integrating the generated model and your business logic. More specifically, I'm used to integration-test my classes that interact with the data store via mocks/stubs of the DAL interfaces. The problem is that you cannot do this using the ADO.NET

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

霸气de小男生 提交于 2019-11-27 10:53: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 separate instance? I'm assuming that it is possible to set up an SQL Server Compact Edition instance, but I

Problem using SQLite :memory: with NHibernate

↘锁芯ラ 提交于 2019-11-27 10:48:19
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=:memory:;Version=3;New=True A SQLite memory database only exists as long as the connection to it

Difference between MockMvc and RestTemplate in integration tests

こ雲淡風輕ζ 提交于 2019-11-27 09:58:31
问题 Both MockMvc and RestTemplate are used for integration tests with Spring and JUnit. Question is: what's the difference between them and when we should choose one over another? Here are just examples of both options: //MockMVC example mockMvc.perform(get("/api/users")) .andExpect(status().isOk()) (...) //RestTemplate example ResponseEntity<User> entity = restTemplate.exchange("/api/users", HttpMethod.GET, new HttpEntity<String>(...), User.class); assertEquals(HttpStatus.OK, entity

What are the pros and cons of automated Unit Tests vs automated Integration tests?

不问归期 提交于 2019-11-27 09:52:18
问题 Recently we have been adding automated tests to our existing java applications. What we have The majority of these tests are integration tests, which may cover a stack of calls like:- HTTP post into a servlet The servlet validates the request and calls the business layer The business layer does a bunch of stuff via hibernate etc and updates some database tables The servlet generates some XML, runs this through XSLT to produce response HTML. We then verify that the servlet responded with the