testing

protractor get element by name tag

让人想犯罪 __ 提交于 2019-12-23 16:12:09
问题 Currently I am working with protractor and Selenium web Driver. I have the following problem: I have a html page, and I make protractor clicking a button. Then a window pops up. This window contains a text box with the Name "Description": <input type="Text" name="Description" ... /> Now when I try the following: element(by.css('[name="Description"]')).sendKeys("rabbababab"); The browser does nothing, but protractor does not throw an error. No text is typed into the TextBox. Unfortunatelly,

Send file to Restful service in codeception

核能气质少年 提交于 2019-12-23 15:19:28
问题 I would like to test restful API test for file uploading. I try to run: $I->sendPOST($this->endpoint, $postData, ['file' => 'example.jpg']); and I would like it to behave the same as user sent example.jpg file in file input with name file but it doesn't seem to work this way. I'm getting: [PHPUnit_Framework_ExceptionWrapper] An uploaded file must be an array or an instance of UploadedFile. Is it possible to upload file using REST plugin in codeception? Documentation is very limited and it's

Sublime Text 3 PHP UNIT

拜拜、爱过 提交于 2019-12-23 15:07:20
问题 In Sublime Text 3 PHP Unit doesn't work. Bundle has installed correctly but plugin is inactive. Has anyone resolved the problem? Thanks in advance. 回答1: I strongly suggest you to use this package which isn't available on Package Control: Sublime-PHPUnit You need to pull this in manually by navigating to ~/Library/Application Support/Sublime Text 3/Packages and paste it in. If you setup a few key binding, the workflow is very snappy. Watch this video for more info: Instant PHPUnit Feedback and

Testing redirections CakePHP 2.0

三世轮回 提交于 2019-12-23 13:27:06
问题 I have been looking at some examples at the cookbook but i dont get it: http://book.cakephp.org/2.0/en/development/testing.html#a-more-complex-example How can i test a redirection in a delete action like this one? public function delete($id = null){ $this->Comment->id = $id; if (!$this->Comment->exists()) { throw new NotFoundException(__('Invalid comment')); } if ($this->Comment->delete()) { $this->Session->setFlash(__('Comment deleted')); return $this->redirect(array('controller' => 'posts',

Mock timing in a context to create models with a field DateTimeField with auto_now_add=True

核能气质少年 提交于 2019-12-23 13:16:19
问题 I'd like to mock timing so that be able to set certain time to a field of type DateTimeField with auto_now_add=True during my tests e.g: class MyModel: ... created_at = models.DateTimeField(auto_now_add=True) ... class TestMyModel(TestCase): ... def test_something(self): # mock current time so that `created_at` be something like 1800-02-09T020000 my_obj = MyModel.objects.create(<whatever>) # and here my_obj.created_at == 1800-02-09T000000 I'm aware the current date is always used for this

Testing website on localhost server for iphone and ipad

我是研究僧i 提交于 2019-12-23 13:15:49
问题 What I'm looking to do is preview what I've built on a custom localhost server (set up with Mamp Pro) on my iphone or ipad. The localhost is under http://devsite:8888 and not http://localhost:8888. I've tried the instructions for something similar found here. The result was being able to see the files but it was just the list of the files on the server and not picking up index.php—no previews enabled. I've triple checked to make sure I have a proper index in the root directory as well. Added

Testing | Cannot read property 'assertPresent' of undefined at resetFakeAsyncZone

被刻印的时光 ゝ 提交于 2019-12-23 13:09:12
问题 I have a problem with karma v1.4. testing framework. All my unit tests are now failing with error Cannot read property 'assertPresent' of undefined at resetFakeAsyncZone I've already searched for solutions and tested them, but unfortunately none helped. The solutions suggests that I should change the order of imports in my test.js file. I've done that. This is the suggested order I am using, but it still fails: import 'zone.js/dist/zone.js'; // 1st import 'zone.js/dist/async-test'; // 2nd

ASP.NET Core UseSetting from integration test

牧云@^-^@ 提交于 2019-12-23 12:49:13
问题 I have an integration tests project that uses .UseSetting() in the test class, as follows: public AccessTokenRetrieval() : base(nameof(AccessTokenRetrieval)) { var connectionString = GetConnectionString(); var dbSettings = new DbSettings(connectionString); _userGroupRepository = new UserGroupRepository(dbSettings); _roleRepository = new RoleRepository(dbSettings); _userRepository = new UserRepository(dbSettings); _server = new TestServer(new WebHostBuilder() .UseStartup<Startup>()

Checking whether function has been called multiple times with different parameters

[亡魂溺海] 提交于 2019-12-23 12:43:17
问题 Assume we have a function f(x,y) and another function def g(): # ... f(i,j) # i,j vary and f is called multiple times # ... We want to write a Unit test that checks whether f is called the number of times and with the right parameters. def test_g(): with patch('mymodule.f') as function: assert function.gacs.call_count == correct_no_calls There is function.assert_called_with(...) but this only refers to the last call. So assuming g calls f(1,2) and then f(2,3) , function.assert_called_with(1,2

How to exclude packages from a context using @WebMvcTest

巧了我就是萌 提交于 2019-12-23 12:41:14
问题 I want to test application slices, but there is a package I want to exclude, since it is not related to those tests at all. I am trying to exclude the package this way: @RunWith(SpringRunner.class) @WebMvcTest(controllers = MyController.class, excludeFilters = {@ComponentScan.Filter( type = FilterType.REGEX, pattern = "com.foo.bar.*")}) public class MyControllerTest { // ... list of test methods goes here ... } Classes from this package are included in a context anyway. How to fix it? 回答1: I