unit-testing

Is there a way to start android emulator in Travis CI build?

♀尐吖头ヾ 提交于 2021-02-18 12:26:26
问题 I have python wrapper-library for adb where I have unit-test which depend on emulator or real device (since they execute adb commands). I want also to use Travis CI as build environment along with executing those unit tests for each build. Is there a way to have android emulator available somewhow in Travis CI, so that unit tests can execute adb commands? Thanks in advance! 回答1: According to the Travis CI documentation, you can start an emulator with the following script in your .travis.yml :

How to mock just the method inside the class

别来无恙 提交于 2021-02-18 12:10:55
问题 Trying to write a testcase for my class based function. This is skeleton of my class class Library(object): def get_file(self): pass def query_fun(self): pass def get_response(self): self.get_file() response = self.query_fun() # some business logic here return response I need to create a testcase that can mock just the query_fun and do the rest. tried below but seems is not the right direction: from unittest import mock, TestCase from library.library import Library class TestLibrary(TestCase)

Test lambda expressions called by dependencies

夙愿已清 提交于 2021-02-18 11:47:31
问题 I am trying to test some code inside lambda expression which is a call back from another class. class EmailSender { private EmailBuilder emailBuilder; public void send() { String testEmail = emailBuilder.buildEmail("Test Email", bodyContentAppender()); //send testEmail } private Consumer<Email> bodyContentAppender() { //how to test this through JUnit? return email -> email.appendBody("Body Content"); } } interface EmailBuilder { String buildEmail(String templateName, Consumer<Email>

check unittest.mock call arguments agnostically w.r.t. whether they have been passed as positional arguments or keyword arguments

折月煮酒 提交于 2021-02-18 11:09:40
问题 When a unittest.mock.Mock object has been called, I can check for the argument values with the exact signature of the call: from unittest.mock import Mock m = Mock() # creation of mock m('foo', bar='baz') # call to the mock m.assert_called_once_with('foo', bar='baz') # check call arguments Checking for a different signature with the same values will fail. E.g., if we check with 'baz' as a positional argument instead of a named argument, the assertion will fail: m.assert_called_once_with('foo'

check unittest.mock call arguments agnostically w.r.t. whether they have been passed as positional arguments or keyword arguments

我是研究僧i 提交于 2021-02-18 11:08:05
问题 When a unittest.mock.Mock object has been called, I can check for the argument values with the exact signature of the call: from unittest.mock import Mock m = Mock() # creation of mock m('foo', bar='baz') # call to the mock m.assert_called_once_with('foo', bar='baz') # check call arguments Checking for a different signature with the same values will fail. E.g., if we check with 'baz' as a positional argument instead of a named argument, the assertion will fail: m.assert_called_once_with('foo'

check unittest.mock call arguments agnostically w.r.t. whether they have been passed as positional arguments or keyword arguments

浪子不回头ぞ 提交于 2021-02-18 11:06:50
问题 When a unittest.mock.Mock object has been called, I can check for the argument values with the exact signature of the call: from unittest.mock import Mock m = Mock() # creation of mock m('foo', bar='baz') # call to the mock m.assert_called_once_with('foo', bar='baz') # check call arguments Checking for a different signature with the same values will fail. E.g., if we check with 'baz' as a positional argument instead of a named argument, the assertion will fail: m.assert_called_once_with('foo'

check unittest.mock call arguments agnostically w.r.t. whether they have been passed as positional arguments or keyword arguments

丶灬走出姿态 提交于 2021-02-18 11:06:29
问题 When a unittest.mock.Mock object has been called, I can check for the argument values with the exact signature of the call: from unittest.mock import Mock m = Mock() # creation of mock m('foo', bar='baz') # call to the mock m.assert_called_once_with('foo', bar='baz') # check call arguments Checking for a different signature with the same values will fail. E.g., if we check with 'baz' as a positional argument instead of a named argument, the assertion will fail: m.assert_called_once_with('foo'

Run JUnit tests from a dependency jar in Eclipse

限于喜欢 提交于 2021-02-18 10:38:49
问题 I have some JUnit tests that contained in a .jar that is intended to be used as a library. The library contains some tests that should be run whenever the library is used in another project. However when I create a new project using the library and run JUnit on it in Eclipse then the tests in the dependency .jar don't run / don't get detected by the JUnit test runner. I get the message: No tests found with test runner 'JUnit 4'. Is there a way I can configure the dependency .jar so that the

Laravel Model Factory without connection to database

感情迁移 提交于 2021-02-18 10:12:23
问题 I would like to use Laravel's Model Factory in some PHPUnit tests. The only thing I want to do is make a Model instance without saving it to database. Why the Model Factory needs connection to database? These tests must pass on CI environment without configured database. When I create Model manually by new App\Model($dataArray) , tests pass and the connection is not needed. I am using Model Factory in other places, so I would like to reuse it in that tests, to avoid code duplication. I am

Laravel Model Factory without connection to database

為{幸葍}努か 提交于 2021-02-18 10:10:34
问题 I would like to use Laravel's Model Factory in some PHPUnit tests. The only thing I want to do is make a Model instance without saving it to database. Why the Model Factory needs connection to database? These tests must pass on CI environment without configured database. When I create Model manually by new App\Model($dataArray) , tests pass and the connection is not needed. I am using Model Factory in other places, so I would like to reuse it in that tests, to avoid code duplication. I am