integration-testing

Capybara doesn't recognize dynamically added DOM elements?

可紊 提交于 2019-12-02 19:15:24
I seem to be having trouble testing the slick javascript things I do with jQuery when using Capybara and Selenium. The expected behavior is for a form to be dynamically generated when a user clicks on the link "add resource". Capybara will be able to click the link, but fails to recognize the new form elements (i.e. "resource[name]"). Is there a way to reload the DOM for Capybara, or is there some element of this gem that I just haven't learned of yet? Thanks in advance! ==Edit== Currently trying my luck with selenium's: wait_for_element method. ==Edit== I keep getting an "undefined method

Inject mock into Spring MockMvc WebApplicationContext

十年热恋 提交于 2019-12-02 18:51:13
I'm working to test (via JUnit4 and Spring MockMvc) a REST service adapter using Spring-boot. The adapter simply passes along requests made to it, to another REST service (using a custom RestTemplate ) and appends additional data to the responses. I'd like to run MockMvc tests to perform controller integration tests, but want to override the RestTemplate in the controller with a mock to allow me to predefine the 3rd party REST response and prevent it from being hit during each test. I've been able to accomplish this by instantiating a MockMvcBuilders.standAloneSetup() and passing it the

Integration testing database, am I doing it right?

不羁岁月 提交于 2019-12-02 18:26:00
I want to test methods in my MVC4 application that rely on and work with a database. I do not want to use mock methods / objects because the queries can be complicated and creating test objects for that is too much of an effort. I found the idea of integration testing that wraps your test's database manipulating logic in a TransactionScope object that rolls back the changes when done. Unfortunately, this does not start with an empty database at first and it also makes the primary keys count on (i.e., when there are already a few items in the database with Primary keys 1 and 2 then after I run

How to test Android UI using IdlingResource when using Retrofit network requests

a 夏天 提交于 2019-12-02 17:39:10
I am writing integration tests that perform actions in the UI which start network calls using Retrofit . I know I need to implement a CountingIdlingResource , but I want to do it the correct way (and not reinvent the wheel if it has already been done). Has anyone implemented an IdlingResource in their app's Espresso test suite to wait while network requests execute? More info here . The most straightforward solution for this: is to basically swap out Retrofit's Thread-pool executor with an AsyncTask one (as recommended by the very helpful Nick from that linked Google group discussion ). I do

Maven separate Unit Test and Integration Tests

依然范特西╮ 提交于 2019-12-02 16:39:13
UT = Unit Tests IT = Integration Tests. All my Integration test classes are annotated with @Category(IntegrationTest.class) My goal is: mvn clean install => runs UT and not IT mvn clean install -DskipTests=true => no tests are executed mvn clean deploy => runs UT and not IT mvn clean test => runs UT and not IT mvn clean verify => runs UT and IT mvn clean integration-test => runs IT and UT are not executed mvn clean install deploy => runs UT and not IT pom properties: <junit.version>4.12</junit.version> <surefire-plugin.version>2.18.1</surefire-plugin.version> <failsafe-plugin.version>2.18.1<

Login with code when using LiveServerTestCase with Django

て烟熏妆下的殇ゞ 提交于 2019-12-02 15:32:46
So I have a Selenium functional test suite. I've already tested login/signup functionality in a few tests by navigating the Selenium client to the signup page, entering in a username and password, and then telling Selenium to login with those same credentials. Now I want to test other parts of the "login required" areas of the site without having to tell Selenium to click and enter text into the test browser. In other words, I would like to use something like this (which I use just fine in my view unit tests): self.client = Client() self.user = User.objects.create_user('temporary', 'temporary

Mocking for integration tests

我只是一个虾纸丫 提交于 2019-12-02 15:30:59
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 database interactions, on multiple external services, the file system, all kinds of things. There are

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

时间秒杀一切 提交于 2019-12-02 14:35:00
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 runs. Yes, I set the :js => true on the containing describe block :) Any ideas would be greatly

Protractor+Mocha fails suite with TypeError before browser loads SUT

时光怂恿深爱的人放手 提交于 2019-12-02 10:09:59
Context I'm exploring angular2 + angular-cli + typescript. My objective is to ensure that if I am doing an angular app or a node app in typescript I would be using the same testing technologies as legacy node apps that use mocha. To this end I am trying to reconfigure the angular-cli generated protractor.conf.js to use mocha instead of jasmine. Question How do you properly integrate angular-cli + mocha + protractor so that tests will execute with protractor actually providing the mocha specs useful browser/element/by components? I've already changed the protractor.conf.js to use mocha and chai

Using unitils/dbMaintain to maintain database, how to exclude scripts from being run?

那年仲夏 提交于 2019-12-02 07:58:42
I am using unitils (and its dbMaintain module) to maintain the state of my local database. dbMaintain has an option to exclude/include scripts based on a qualifier. See http://www.dbmaintain.org/tutorial.html#Qualifier_inclusion__exclusion . In my project, excludes/includes do not work when running from a Unitils test with the UnitilsJUnit4TestClassRunner . My script hierarchy: unitils/ 01_create/ <lots of scripts here> 02_lkups/ <lots of scripts here> 03_#testdata/01_#testdata_master/05_#testdata_master_rate_offer.sql My unitils.properties file has: updateDataBaseSchema.enabled=true