stub

stub method with block of code as parameter with OCMock

狂风中的少年 提交于 2019-12-05 10:36:10
Is there a way to stub method, that takes block as it's parameter? For example mehod: - (void)reverseGeocodeLocation:(CLLocation *)location completionHandler:(CLGeocodeCompletionHandler)completionHandler; Yes. The easiest way would be to accept anything: id mockGeocoder = [OCMockObject mockForClass:[CLGeocoder class]]; [[mockGeocoder stub] reverseGeocodeLocation:[OCMOCK_ANY] completionHandler:[OCMOCK_ANY]]; It gets a bit trickier if you want to verify a particular block is passed in. One option is to make your completion handler a property of your class, initialize it when you initialize your

Why are some dll static-linking stub libs (import libraries) so big?

折月煮酒 提交于 2019-12-05 10:26:46
I noticed while linking to the pcl (point cloud library) that some of the dll stub libs have more than 10MB where the dll themselves have less than half of that size (these are release builds!). Shouldn't the stub lib only contain minimal information so that the dll information is accessible? How can it be larger than the dll files they refer to? The relevancy for me is that by linking to the big stub libs, my own executables are also greatly growing in size; something I wanted to prevent by using dlls. Are there settings in VS that change the dll linker behavoiur so that it puts more or less

SQL server stub for java

ぃ、小莉子 提交于 2019-12-05 09:27:45
I have a java application that is using MSSQL server through the JDBC driver. Is there some kind of stub that I can use for testing? For example I want to test how my application handle cases of connection errors, SQL server out of disk, and other exceptions. It's pretty hard and complex to simulate this with real SQL server. Thanks You could write unit tests against your DAO s or repositories returning mock Connection objects using a mock library such as https://mocquer.dev.java.net/ . You'd need a really clean and decoupled application architecture though in order to make this work correctly

meaning of RuntimeException(“Stub!”) in Android

こ雲淡風輕ζ 提交于 2019-12-05 08:45:23
问题 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! 回答1: This is because source code is not found in SDK. To see the source code, you need to download

Mock fs.readdir for testing

大憨熊 提交于 2019-12-05 06:37:51
I'm trying to mock the function fs.readdir for my tests. At first I've tried to use sinon because this is a very good framework for this, but is hasn't worked. stub(fs, 'readdir').yieldsTo('callback', { error: null, files: ['index.md', 'page1.md', 'page2.md'] }); My second attempt was to mock the function with a self-replaced function. But it also doesn't works. beforeEach(function () { original = fs.readdir; fs.readdir = function (path, callback) { callback(null, ['/content/index.md', '/content/page1.md', '/content/page2.md']); }; }); afterEach(function () { fs.readdir = original; }); Can

laravel create model from custom stub when using php artisan

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 05:54:07
When I use php artisan make:model CustomNamespace\TestModel , I get a model based on default stub as this : namespace App\Models\CustomNamespace; use Illuminate\Database\Eloquent\Model; class TestModel extends Model { // } But what I want to create is a dynamic Model based on my own stub to get something like this: namespace App\Models\CustomNamespace; use App\Models\MyParent; /** * Put a dynamic doc here */ class MyModel extends MyParent { /*put custom methods here*/ } I've checked Laravel docs and other tutos but nothing on this, could you help guys ? Create a new command, extend the

Using Moq to Stub an interface method [duplicate]

感情迁移 提交于 2019-12-05 01:26:04
Possible Duplicate: How to mock a method that returns an int with MOQ Here's my interface: public interface ICalenderService { DateTime Adjust(DateTime dateToAdjust, BusinessDayConvention convention, List<HolidayCity> holidayCities); } I've done some research and it seems you can mock this real easily, but I want to stub this out using Moq so that I can pass the stub into my other class constuctors and have the stub return whatever DateTime I want for its Adjust method. What's the easiest way to do this? Edit: I know I can create my own stub in my project, but I'd like to write less code, and

Android unit testing with Junit: testing network/bluetooth resources

拈花ヽ惹草 提交于 2019-12-04 23:05:24
I am slowly becoming obsessed with unit testing. I am trying to develop as much software as I can using test-driven development. I am using JUnit to unit test my android applications. I have been working on an app that uses bluetooth and am having a hard time unit testing it. I have an Activity that uses BluetoothAdapter to obtain a list of paired and discovered devices. Although it works, I would like to know how to unit test it. To get the list of paired devices, I call getBondedDevices() on the instance of BluetoothAdapter. The problem is I don't know how to stub or mock this method (or any

Overriding functions in other modules in node.js

时间秒杀一切 提交于 2019-12-04 12:44:16
I'm trying to stub a function with nodeunit in a Node.js app. Here's a simplified version of what I'm trying to do: In lib/file.js : var request = require('request'); var myFunc = function(input, callback){ request(input, function(err, body){ callback(body); }); }; In test/test.file.js : var file = require('../lib/file'); exports['test myFunc'] = function (test) { request = function(options, callback){ callback('testbody'); }; file.myFunc('something', function(err, body){ test.equal(body, 'testbody'); test.done(); }); }; It seems like I'm not overriding request properly, because when I try to

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

陌路散爱 提交于 2019-12-04 11:28:48
问题 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? 回答1: 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