tdd

Version control and test-driven development

最后都变了- 提交于 2020-01-12 17:39:43
问题 The standard process for test-driven development seems to be to add a test, see it fail, write production code, see the test pass, refactor, and check it all into source control. Is there anything that allows you to check out revision x of the test code, and revision x-1 of the production code, and see that the tests you've written in revision x fail? (I'd be interested in any language and source control system, but I use ruby and git) There may be circumstances where you might add tests that

“autotest/rails […] doesn't […] exist. Aborting”

梦想的初衷 提交于 2020-01-12 03:25:08
问题 I'm finding that autotest has stopped working... $ autotest loading autotest/rails Autotest style autotest/rails doesn't seem to exist. Aborting. According to this blog post, the common reason for this error is that people don't have the autotest-rails gem installed. However, I definitely have that installed: autotest-rails (4.1.0) ZenTest (4.1.4, 4.1.3, 4.1.1, 4.0.0, 3.11.1, 3.11.0, 3.10.0, 3.9.3, 3.9.2) I haven't installed any new gems today or yesterday, though I might have done a gem

Philisophical Questions about Test-Driven Development

喜欢而已 提交于 2020-01-11 17:10:50
问题 I have been perpetually intrigued by test-driven development, but I can never follow through with it when I try it on real projects. I have a couple of philosophical questions that continually arise when I try it: How do you handle large changes? When it comes to testing single functions (some parameters, a result value, few side effects), TDD is a no-brainer. But what about when you need to thoroughly overhaul something large, e.g. switching from a SAX parsing library to a DOM parsing

Philisophical Questions about Test-Driven Development

早过忘川 提交于 2020-01-11 17:10:46
问题 I have been perpetually intrigued by test-driven development, but I can never follow through with it when I try it on real projects. I have a couple of philosophical questions that continually arise when I try it: How do you handle large changes? When it comes to testing single functions (some parameters, a result value, few side effects), TDD is a no-brainer. But what about when you need to thoroughly overhaul something large, e.g. switching from a SAX parsing library to a DOM parsing

Using Moq, how do I set up a method call with an input parameter as an object with expected property values?

╄→尐↘猪︶ㄣ 提交于 2020-01-11 17:09:29
问题 var storageManager = new Mock<IStorageManager>(); storageManager.Setup(e => e.Add(It.IsAny<UserMetaData>())); The Add() method expects a UserMetaData object which has a FirstName property. I'd like to make sure that an object of type UserMetaData with the FirstName of "FirstName1" has been passed. 回答1: You can use Verify . Examples: Verify that Add was never called with an UserMetaData with FirstName != "FirstName1" : storageManager.Verify(e => e.Add(It.Is<UserMetaData>(d => d.FirstName!=

ATDD versus BDD and the proper use of a framework

南楼画角 提交于 2020-01-11 15:26:18
问题 I am just getting into the concept of BDD and have listened to Scott Bellware's talk with the Herding Code guys. I have been playing around with SpecFlow some and like it pretty well. I understand the distinction between ATDD and TDD as described in the blog post Classifying BDD Tools (Unit-Test-Driven vs. Acceptance Test Driven) and a bit of BDD history, but that leads me to a question. As described, isn't using a BDD tool (such as MSpec) just another unit testing framework? It seems to me

Mocking iterative behaviour

让人想犯罪 __ 提交于 2020-01-11 14:00:31
问题 I have an interface with iterative behaviour, and I am having trouble Mocking that in Rhinomocks. The example interface and class is a very simple version of my problem. Every time LineReader.Read() is called, the LineReader.CurrentLine() should return a different value -- the next line. This behaviour I haven't been able to reproduce in a mock so far. Thus, it has become a small hobby project of mine which I return to from time to time. I hope you can help me a step further. internal class

从一个案例深刻领悟TDD的真谛

偶尔善良 提交于 2020-01-10 14:33:54
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 一直以来比较推崇在开发中进行全面的单元测试,我觉得单元测试的好处非常多。但是没有真正的用起TDD,在编写功能实现代码之前先编写测试代码,这样的习惯没有养成,意义也没有觉得非常大。因此TDD其实没有真正用起来。 直到最近在实际工作中的一个案例让我更加深刻得领悟出TDD开发的真谛! 案例:最近我们开发一个消息中心的服务,该服务要给数十个项目组提供接口,由于各项目组的进度和步调不一致,消息中心服务的项目先开始工作,定义好了接口之后,将接口公布出去,然后就开始实现接口功能,进行接口的单元测试及模拟集成测试。一段时间后,陆陆续续有些应用项目组开始工作,发现了接口定义的一些问题,这些问题有的是接口无法满足他们的需求;有的是有些字段没有;有的是感觉接口使用不方便;反正最终导致的结果是消息中心服务项目组的代码进行了多次返工和修改,浪费了很多时间,至今还没有彻底满足所有项目组的需求。 后来我接收负责其中一个接口的实现,反思之前出现的问题的原因是什么?有什么办法可以解决或者减轻这种问题呢?我觉得最根本的原因是在设计和实现接口的时候,服务提供项目组没有让服务的用户参与进来一起进行设计,服务接口公布出去之后,由于服务用户没有真正去了解和使用,也无法提出问题,等真正开始使用的时候才发现一大堆问题

How do you test code written against AWS API [closed]

佐手、 提交于 2020-01-10 07:58:12
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 8 months ago . I'm writing an application in Java that will upload a file up to AWS S3. The file will be given to the application in an argument, not hardcoded. I'd like to write tests to ensure that the file actually gets uploaded to S3. The test will be written before the code for TDD. (I

Get Stored Procedure from Data Context : Linq to SQl

痴心易碎 提交于 2020-01-10 05:24:47
问题 I have a stored procedure named ParseXML in SQL Server. I have a repository pattern using LINQ to SQL. I need to call the stored procedure from within the repository layer. Unlike GetTable method, we don’t have a GetStoredProcedure method for data context. How can we call the stored procedure in such a scenario? Dbml Code [global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.ParseXML")] public ISingleResult<ParseXMLResult> ParseXML([global::System.Data.Linq.Mapping.ParameterAttribute