integration-testing

How to make a docker image with a populated database for automated tests?

ぐ巨炮叔叔 提交于 2019-12-10 10:56:12
问题 I want to create containers w/ a MySQL db and a dump loaded for integration tests. Each test should connect to a fresh container, with the DB in the same state. It should be able to read and write, but all changes should be lost when the test ends and the container is destroyed. I'm using the "mysql" image from the official docker repo. 1) The image's docs suggests taking advantage of the "entrypoint" script that will import any .sql files you provide on a specific folder. As I understand,

How-to organize integration tests and unit tests

こ雲淡風輕ζ 提交于 2019-12-10 10:55:54
问题 Is it ok to have integration tests and unit tests in one assembly (project) ? Or rather have them separate ? 回答1: Personally I prefer to put them into separate assemblies. During continuous integration builds it is easier to distinguish between them because tools can be configured to execute all tests in a given assembly and you could for example want to run only unit tests or only integration tests which might take more time. 来源: https://stackoverflow.com/questions/3922548/how-to-organize

Grails IntegrationSpec IllegalStateException

笑着哭i 提交于 2019-12-10 10:29:58
问题 After upgrading to 2.4.2 from 2.4.0, I am getting an error when I run my integration tests. It shows that the tests passed, however I am getting an IllegalStateException. Failure: | massemailsystem.UserInformationIntegrationSpec | java.lang.IllegalStateException: Could not find ApplicationContext, configure Grails correctly first at grails.util.Holders.getApplicationContext(Holders.java:97) at grails.test.spock.IntegrationSpec.$spock_initializeSharedFields(IntegrationSpec.groovy:41) I tried

Integration tests implementation

我的梦境 提交于 2019-12-10 09:28:02
问题 I have a three tiered app web app (asp.net mvc for simplicity here), business services data repositories And I know there are four types of integration tests: top down bottom up sandwich (combination of the top two) big bang I know I would write big-bang tests just like unit tests but without any mocking so I would employ a backend DB as well... Questions I don't know how to write other types of integration tests? How do I write non-bigbang types of integration tests? Should integration tests

ASP.NET Core Integration Test works locally but throws null reference exception when running in production environment

旧巷老猫 提交于 2019-12-10 07:35:37
问题 I have an ASP.NET Core 2.2 Razor Pages Web App that I have written some integration tests for following the official guide. I can get the tests to run locally using dotnet test or the test runners built into Visual Studio. However, on the build server (Azure DevOps Hosted 2017 agent) the tests will return a 500 error. I thought it might be related to user secrets as stated on Scott Hanselman's guide but I am still getting the same error, even after implementing some of his suggested fixes (I

how to test the CRUD service which only invoke the repository (dao) layer?

♀尐吖头ヾ 提交于 2019-12-10 05:52:49
问题 for example, we have a layer of service that simple invoke the JpaRepository method. usual crud public List<User> findAll() { return userRepository.findAll(); } how to correctly test such methods? just that the service invokes the dao layer? @Mock private UserRepository userRepository; @Test public void TestfindAllInvokeUserServiceMethod(){ userService.findAll(); verify(userRepository.findAll()); } upd: ok, findAll() is simple example, when we using when(userRepository.findAll()).thenReturn

Accessing Spring beans in JerseyTest

谁说我不能喝 提交于 2019-12-10 04:11:47
问题 I'm trying to figure out how to access Spring beans from a subclass of JerseyTest. Extending JerseyTest I've managed to load the Spring context in my tests, but I haven't figured out how to access the spring context. My setup looks like this: public abstract class SpringJerseyTest extends JerseyTest { public SpringJerseyTest() throws Exception { super(new WebAppDescriptor.Builder("com.acme.resources") .contextPath("/") .contextParam("contextConfigLocation", "classpath:applicationContext.xml")

Rails integration test with the devise gem

老子叫甜甜 提交于 2019-12-10 03:39:45
问题 I want to write an rails integration test (with ActionDispatch::IntegrationTest ). I am using devise for authentication and machinist for test models. I cannot successfully sign in. Here is a simple example: class UserFlowsTest < ActionDispatch::IntegrationTest setup do User.make end test "sign in to the site" # sign in post_via_redirect 'users/sign_in', :email => 'foo@bar.com', :password => 'qwerty' p flash p User.all end Here is the debug output: Loaded suite test/integration/user_flows

Testing in “Airplane” mode in Android Emulator

送分小仙女□ 提交于 2019-12-10 02:02:15
问题 I'm trying to test my application for situations when the phone has no connection to the internet. In my emulator, I turned on Airplane Mode in the settings. However, my app still seemed to be able to communicate with my server. It works as normal. On my device, the same code throws an error with no data connection. How can I ensure that there is no internet connection in the emulator so I can use LogCat etc to analyze the code. 回答1: You can switch off Internet access by pressing F8 in the

I want to test a private method - is there something wrong with my design? [duplicate]

安稳与你 提交于 2019-12-10 01:49:54
问题 This question already has answers here : How do I test a private function or a class that has private methods, fields or inner classes? (51 answers) Closed last year . So I'm extremely new to software testing, and am looking at adding a couple of tests to one of my applications. I have a public method addKeywords() which along the way calls a private method removeInvalidOperations(). This private method makes calls to an external API and is ~50 lines of code. As I consider this to be a