tdd

Test cases for go and appengine

别说谁变了你拦得住时间么 提交于 2019-11-28 19:41:45
I am using Go and appengine, and now I would like to do some test cases. I tried using gos standard test package, Files (both "package hello"): hello/http.go hello/http_test.go Problem: I cannot run go test hello . The closest I have got is go test hello/http_test.go which works if I do not make any calls to http.go , which is quite pointless. :) An interesting development: as of 1.8.6 using service stubs for testing has been integrated into the SDK through the "appengine/aetest" package. This works largely like the above via a "testing" context. More info github.com/mzimmerman

Using TDD to drive out thread-safe code

廉价感情. 提交于 2019-11-28 18:58:00
What's a good way to leverage TDD to drive out thread-safe code? For example, say I have a factory method that utilizes lazy initialization to create only one instance of a class, and return it thereafter: private TextLineEncoder textLineEncoder; ... public ProtocolEncoder getEncoder() throws Exception { if(textLineEncoder == null) textLineEncoder = new TextLineEncoder(); return textLineEncoder; } Now, I want to write a test in good TDD fashion that forces me to make this code thread-safe. Specifically, when two threads call this method at the same time, I don't want to create two instances

How do you unit test an interface?

别说谁变了你拦得住时间么 提交于 2019-11-28 18:43:54
For example, there is a interface IMyInterface , and three classes support this interface: class A : IMyInterface { } class B : IMyInterface { } class C : IMyInterface { } In the simplest way, I could write three test class : ATest, BTest, CTest and test them separately. However, since they support the same interface, most test code would be the same, it's hard to maintain. How can I use a simple and easy way to test a interface that is supported by different class? ( previously asked on the MSDN forums ) To test an interface with common tests regardless of implementation, you can use an

How to set execution order of mocha test cases in multiple files

自作多情 提交于 2019-11-28 18:35:56
I have two javascript files which contain mocha test cases. //----------abc.js ------------- describe("abc file", function(){ it("test 1" , function(){ assert.equal(20 , 20); }); }); //---------xyz.js-------------- describe("xyz file", function(){ it("test 1" , function(){ assert.equal(10 , 10); }); }); I have put them in a folder called test and when I execute the mocha command the first file(abc.js) is always executed before xyz.js. I thought this might be due to alphabetical ordering and renamed the files as abc.js => xyz.js xyz.js => abc.js but still, the content of the xyz.js (previously

Test Driven Design for iPhone Native apps

别来无恙 提交于 2019-11-28 18:23:54
I'm experimenting with the iPhone SDK and doing some TDD ala Dr. Nic's rbiPhoneTest project. I'm wondering how many, if any, have been successful using this or any other testing framework for iPhone/Cocoa? More important, I'd like to know how to best assert a proprietary binary request/response protocol. The idea is to send a binary request over the network and receive a binary response. Requests and responses are created using byte and'ing and or'ing. I'm using the golden copy pattern to test my request. Here's what I have so far. Don't laugh as I'm new to btoh Objective C and Ruby: require

Unit Testing Guidelines

孤街醉人 提交于 2019-11-28 18:19:23
Does anyone know of where to find unit testing guidelines and recommendations? I'd like to have something which addresses the following types of topics (for example): Should tests be in the same project as application logic? Should I have test classes to mirror my logic classes or should I have only as many test classes as I feel I need to have? How should I name my test classes, methods, and projects (if they go in different projects) Should private, protected, and internal methods be tested, or just those that are publicly accessible? Should unit and integration tests be separated? Is there

Run logic tests in Xcode 4 without launching the simulator

被刻印的时光 ゝ 提交于 2019-11-28 18:15:56
I want to run tests in Xcode 4 using OCUnit without launching the simulator. Please, don't try and convince me I am doing unit testing wrong or anything like that. I like to do TDD the traditional way: write the API for the class in the tests, then make the class pass the tests. I will write separate tests that are end-to-end that run in the simulator. If there's no way to do this, then please can someone tell me how to have the test harness not instantiate the whole app? My app is event driven, and it sends a bunch of events through when it starts up that mess with my tests. Please can

TDD and ADO.NET Entity Framework

僤鯓⒐⒋嵵緔 提交于 2019-11-28 17:57:46
I've been playing with ADO.NET Entity Framework lately, and I find that it suits my needs for a project I'm developing. I also find cool its non-invasive nature. After generating a data model from an existing database you are faced with the task of integrating the generated model and your business logic. More specifically, I'm used to integration-test my classes that interact with the data store via mocks/stubs of the DAL interfaces. The problem is that you cannot do this using the ADO.NET Entity Framework because the entities it generates are simple classes with no interface. The question is:

Is it feasible to introduce Test Driven Development (TDD) in a mature project? [closed]

我的梦境 提交于 2019-11-28 17:48:38
Say we have realized a value of TDD too late. Project is already matured, good deal of customers started using it. Say automated testing used are mostly functional/system testing and there is a good deal of automated GUI testing. Say we have new feature requests, and new bug reports (!). So good deal of development still goes on. Note there would already be plenty of business object with no or little unit testing. Too much collaboration/relationships between them, which again is tested only through higher level functional/system testing. No integration testing per se. Big databases in place

NSURL to file path in test bundle with XCTest

只谈情不闲聊 提交于 2019-11-28 17:19:17
问题 I am trying to write an iOS app using TDD and the new XCTest framework. One of my methods retrieves a file from the internet (given a NSURL object) and stores it in the user's documents. The signature of the method is similar to: - (void) fetchAndStoreImage:(NSURL *)imageUrl I'm trying to write the test for this method in a way that it doesn't fail if there is no connection to the internet. My approach (taken from a previous question) is to call the method using a NSURL to an image in the