tdd

Design By Contract and Test-Driven Development [closed]

瘦欲@ 提交于 2019-12-17 17:28:57
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 6 months ago . I'm working on improving our group's development process, and I'm considering how best to implement Design By Contract with Test-Driven Development. It seems the two techniques have a lot of overlap, and I was wondering if anyone had some insight on the following (related)

Mocha breakpoints using Visual Studio Code

戏子无情 提交于 2019-12-17 17:24:25
问题 Is it possible to add breakpoints to ones Mocha tests using Visual Studio Code? Normally when debugging code one need to configure the launch.json, setting the program attribute to the javascript file to execute. I am not sure how to do this for for Mocha though. 回答1: Did you know, that you just go into your launch config, put your cursor after or between your other configs and press ctrl - space to get a current, valid mocha config auto-generated? Which works perfectly fine for me. Including

How to MOQ an Indexed property

让人想犯罪 __ 提交于 2019-12-17 16:24:10
问题 I am attempting to mock a call to an indexed property. I.e. I would like to moq the following: object result = myDictionaryCollection["SomeKeyValue"]; and also the setter value myDictionaryCollection["SomeKeyValue"] = myNewValue; I am doing this because I need to mock the functionality of a class my app uses. Does anyone know how to do this with MOQ? I've tried variations on the following: Dictionary<string, object> MyContainer = new Dictionary<string, object>(); mock.ExpectGet<object>( p =>

What is a “Stub”?

戏子无情 提交于 2019-12-17 15:19:20
问题 So, carrying on with my new years resolution to get more in to TDD, I am now starting to work more with Rhino Mocks. One thing I am keen to do is to make sure I really grok what I am getting in to, so I wanted to check my understanding of what I have seen so far (and I thought it would be good to get it up here as a resource). What is a "Stub"? 回答1: Martin Fowler wrote an excellent article on this subject. From that article: Meszaros uses the term Test Double as the generic term for any kind

Insert blob in oracle database with C#

青春壹個敷衍的年華 提交于 2019-12-17 11:08:29
问题 I have to persist a .csv in my database, but for a more testable application I prefer don't use procedures. Basically I just generate a file and the next instruction is put this in database. Someone have some clue about best way to do this in code? 回答1: Here is an example to insert blob data in oracle using c# and procedures (you said prefer that means you may). using System; using System.Data; using Oracle.DataAccess.Client; using Oracle.DataAccess.Types; using System.IO; using System.Text;

Testing asynchronous function with mocha

ε祈祈猫儿з 提交于 2019-12-17 09:36:27
问题 I want to test a asynchronous javascript function that runs in node.js and makes a simple request to a http api: const HOST = 'localhost'; const PORT = 80; http = require('http'); var options = { host: HOST, port: PORT, path: '/api/getUser/?userCookieId=26cf7a34c0b91335fbb701f35d118c4c32566bce', method: 'GET' }; doRequest(options, myCallback); function doRequest(options, callback) { var protocol = options.port == 443 ? https : http; var req = protocol.request(options, function(res) { var

Testing asynchronous function with mocha

笑着哭i 提交于 2019-12-17 09:36:12
问题 I want to test a asynchronous javascript function that runs in node.js and makes a simple request to a http api: const HOST = 'localhost'; const PORT = 80; http = require('http'); var options = { host: HOST, port: PORT, path: '/api/getUser/?userCookieId=26cf7a34c0b91335fbb701f35d118c4c32566bce', method: 'GET' }; doRequest(options, myCallback); function doRequest(options, callback) { var protocol = options.port == 443 ? https : http; var req = protocol.request(options, function(res) { var

Mocking free function

别说谁变了你拦得住时间么 提交于 2019-12-17 06:46:11
问题 I am stuck in a problem and can't seem to find the solution. I am using VS2005 SP1 for compiling the code. I have a global function: A* foo(); I have a mock class class MockA : public A { public: MOCK_METHOD0 (bar, bool()); ... }; In the sources, it is accessed like this: foo()->bar() . I cannot find a way to mock this behavior. And I cannot change the sources, so the solution in google mock cook book is out of question. Any help or pointers in the right direction will be highly appreciated.

test a file upload using rspec - rails

流过昼夜 提交于 2019-12-17 04:40:29
问题 I want to test a file upload in rails, but am not sure how to do this. Here is the controller code: def uploadLicense #Create the license object @license = License.create(params[:license]) #Get Session ID sessid = session[:session_id] puts "\n\nSession_id:\n#{sessid}\n" #Generate a random string chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a newpass = "" 1.upto(5) { |i| newpass << chars[rand(chars.size-1)] } #Get the original file name upload=params[:upload] name = upload[

test a file upload using rspec - rails

拥有回忆 提交于 2019-12-17 04:40:15
问题 I want to test a file upload in rails, but am not sure how to do this. Here is the controller code: def uploadLicense #Create the license object @license = License.create(params[:license]) #Get Session ID sessid = session[:session_id] puts "\n\nSession_id:\n#{sessid}\n" #Generate a random string chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a newpass = "" 1.upto(5) { |i| newpass << chars[rand(chars.size-1)] } #Get the original file name upload=params[:upload] name = upload[