stub

Codeception\\Util\\Stub methods ::exactly and ::once don't work

你。 提交于 2019-12-04 03:13:19
I am using Codeception\Util\Stub to create unit tests. And I want to be sure that my method called several times. For this I am using method 'exactly'. Example: use \UnitTester; use \Codeception\Util\Stub as StubUtil; class someCest { public function testMyTest(UnitTester $I) { $stub = StubUtil::makeEmpty('myClass', [ 'myMethod' => StubUtil::exactly(2, function () { return 'returnValue'; }) ]); $stub->myMethod(); } } As you can see I called myMethod once. But test passed. The same problem with method ::once , because this method is using the same class PHPUnit_Framework_MockObject_Matcher

Parsing C++ to generate unit test stubs

霸气de小男生 提交于 2019-12-04 00:27:08
问题 I've recently been trying to create units tests for some legacy code. I've been taking the approach of using the linker to show me which functions cause link errors, greping the source to find the definition and creating a stub from that. Is there an easier way? Is there some kind of C++ parser that can give me class definitions, in some easy to use form, from which I can generate stubs? 回答1: You may want to investigate http://os.inf.tu-dresden.de/vfiasco/related.html#parsing. But C++ parsing

meaning of RuntimeException(“Stub!”) in Android

三世轮回 提交于 2019-12-03 22:09:55
I was surfing in Android code because I wanted to see what is into Activity.finish() method. I just wanted to have the confirmation that in Activity.finish() there would be a call to onDestroy() method. But what I found in this method (and in many others) was: public void finish() { throw new RuntimeException("Stub!"); } So WHERE Can I find the code that really destroys the Activity? Thanks! hakim This is because source code is not found in SDK. To see the source code, you need to download source for Android SDK, so Android studio can display the respective code. I don't know where you looked,

Stubbing a React component method with Sinon

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 11:53:07
问题 I'm trying to stub a React component method for testing purpose: var Comp = React.createClass({ displayName: "Comp", plop: function() { console.log("plop"); }, render: function() { this.plop(); return React.DOM.div(null, "foo"); } }); var stub = sinon.stub(Comp.type.prototype, "plop"); React.addons.TestUtils.renderIntoDocument(Comp()); sinon.assert.called(stub); // throws This sadly keeps printing "plop" onto the console… and the assertion fails. Note: Directly stubbing the spec object method

How to stub Python methods without Mock

≡放荡痞女 提交于 2019-12-03 10:27:21
问题 I'm a C# dev moving into some Python stuff, so I don't know what I'm doing just yet. I've read that you don't really need Dependency Injection with Python. I've been told you can instantiate objects in your code and have them run the way you want, however, you can point methods on those objects to my own stubs defined in my tests - supposedly without mocks. Is this true? I've tried to do it and can't quite get it working. How is this actually done? How do I stub a method in Python without a

RSpec: how to stub inherited method current_user (w/o Devise)?

寵の児 提交于 2019-12-03 09:40:28
I have a controller based on MHartl's RoR4 Tutorial And just like MHartl, I'm not using Devise , I rolled my own authentication system Having trouble with the RSpec for UsersController#Edit since the view has a call to current_user.admin? and the controller calls @path_switch = path_switch I keep getting RSpec errors along the lines of: 1) User Pages Edit Failure/Error: visit edit_user_path(user) NoMethodError: undefined method `admin?' for nil:NilClass # ./app/controllers/users_controller.rb:106:in `path_switch' # ./app/controllers/users_controller.rb:53:in `edit' # ./spec/requests/user_pages

Is there any simulator/tool to generate messages for streaming?

感情迁移 提交于 2019-12-03 07:11:12
For testing purpose, I need to simulate client for generating 100,000 messages per second and send them to kafka topic. Is there any tool or way that can help me generate these random messages? There's a built-in tool for generating dummy load, located in bin/kafka-producer-perf-test.sh ( https://github.com/apache/kafka/blob/trunk/bin/kafka-producer-perf-test.sh ). You may refer to https://github.com/apache/kafka/blob/trunk/tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java#L106 to figure out how to use it. One usage example would be like that: bin/kafka-producer-perf-test.sh

Please explain how to create PHP's Phar stubs

安稳与你 提交于 2019-12-03 05:00:54
I'm trying to create a very simple PHP CLI application that can be run as a phar file from the command line: # php myProject.phar This is what I've tried so far: My Project My project is in a directory called MyProject and it has these two files in it: |-- createPhar.php `-- bootstrap.php bootstrap.php The bootstrap.php file contains this: <?php print phpversion() . PHP_EOL; print 'i am some script' . PHP_EOL; When I run this script from my Ubuntu command line: # cd MyProject # php bootstrap.php I get the following output: 5.3.2-1ubuntu4.9 i am some script createPhar.php The createPhar.php

What is double method in rspec for?

半城伤御伤魂 提交于 2019-12-03 04:14:09
问题 It is stated in rspec doc that I should use double method in order to create test double. But I can see that it works perfectly ok even if I don't use double . Is there anything wrong with not using double ? Also if I'm not using double how MyClass gets stub and other rspec methods? Are they available for all objects when running in rspec? require 'spec_helper' class MyClass def self.run new.execute end def execute 'foo' end end describe MyClass do it 'should stub instance method' do obj =

Stubbing a React component method with Sinon

懵懂的女人 提交于 2019-12-03 01:23:29
I'm trying to stub a React component method for testing purpose: var Comp = React.createClass({ displayName: "Comp", plop: function() { console.log("plop"); }, render: function() { this.plop(); return React.DOM.div(null, "foo"); } }); var stub = sinon.stub(Comp.type.prototype, "plop"); React.addons.TestUtils.renderIntoDocument(Comp()); sinon.assert.called(stub); // throws This sadly keeps printing "plop" onto the console… and the assertion fails. Note: Directly stubbing the spec object method works, but then you have to export the component constructor and the spec separately so they're both