tdd

View Controller TDD

风格不统一 提交于 2019-11-30 08:54:37
I am trying to add some unit tests to my project to test view controllers. However I seem to be having problems with seemingly simple things. I have created a sample project which I will refer to. https://github.com/pangers/ViewControllerTesting The sample contains a UINavigationController as the initial view controller. The root view controller of the UINavigationController is FirstViewController. There is a button on FirstViewController that segues to SecondViewController. In SecondViewController there is an empty textfield. The two tests I am trying to add are: 1) Check button title in

Unit Testing a large method

人盡茶涼 提交于 2019-11-30 08:36:16
问题 Following Test-Driven Development that is. I've recently implemented a algorithm (A*) that required a clean interface. By clean all I want is a couple of properties and a single search method. What I've found hard is testing the search method. It contains around five steps but I'm essentially forced to code this method in one big go which makes things hard. Is there any advice for this? Edit I'm using C#. No I don't have the code at hand at the moment. My problem relies in the fact a test

How do I test Prism event aggregator subscriptions, on the UIThread?

纵然是瞬间 提交于 2019-11-30 08:31:44
I have a class, that subscribes to an event via PRISMs event aggregator. As it is somewhat hard to mock the event aggregator as noted here , I just instantiate a real one and pass it to the system under test. In my test I then publish the event via that aggregator and then check how my system under test reacts to it. Since the event will be raised by a FileSystemWatcher during production, I want to make use of the automatic dispatch by subscribing on the UIThread, so I can update my UI once the event is raised. The problem is, that during the test, the event never gets noticed in the system

Should I write unit test for everything?

≯℡__Kan透↙ 提交于 2019-11-30 08:23:06
I am wondering should I write unit test for everything. There are some classes is very difficult to write unit test. For example, I am writing some program for handling audio. The class for capturing audio from microphone, and class for play audio to speaker, how can I write unit test for those classes? I can't get output and input of those classes, so it is almost impossible to test them? The only test I can do is for getter and setter, those boring test. So the question is, what is the guide line for writing unit test? And how should I deal with these classes are difficult to test? Use unit

Show runtime for each rspec example

∥☆過路亽.° 提交于 2019-11-30 08:07:54
currently I'm running more than 1k examples and it's taking a long time to complete (more than 20 minutes!!! ). I'd like to identify which examples are the ones taking more time to complete, is there any way to run rspec and return the time each example takes to complete(individually)? I'm using rspec 1.3.0 and rspec-rails 1.2.3 Pan Thomakos You can use profiling to list your 10 slowest examples: spec -p spec/*/*_spec.rb --colour --format profile If you run this on a specific test suite you can get the 10 slowest examples from a smaller subset of examples: spec -p spec/models/user_spec.rb -

How to mock File in javascript?

纵饮孤独 提交于 2019-11-30 07:55:55
I'm developing some small project to exercise my TDD skills. The project consists of an audio player which has the ability to drag'n'drop files in a playlist. I'm using Jasmine as a testing framework. The problem I faced is that I can't mock javascript files to test my file upload functionality. I tried to create a File like this: new File(new Blob(), "name"); but Chrome does not allow creating files manually. File's constructor is illegal to use. I found a solution with grunt.js which consists of returning some files from grunt, but I don't really wanna use server-side for such a small test

In TDD, why OpenEJB and why Arquillian?

霸气de小男生 提交于 2019-11-30 07:25:46
I'm a web developer ended up in some Java EE development (Richfaces, Seam 2, EJB 3.1, JPA). To test JPA I use hypersonic and Mockito. But I lack deeper EJB knowledge. Some may argue that we should use OpenEJB and Arquillian, but for what? When do I need to do container dependent tests? What are the possible test scenarios where I need OpenEJB and Arquillian? Please enlighten me :) Piotr Nowicki There are two aspects in this case. Unit tests . These are intended to be very fast (execute the whole test suite in seconds). They test very small chunks of your code - i.e. one method. To achieve this

Detecting console.log() calls

爱⌒轻易说出口 提交于 2019-11-30 07:25:34
I'm trying to write a test case for a debugging method that writes messages to the JavaScript console using console.log() . The test has to check that the message has been successfully written to the console. I'm using jQuery. Is there a way to attach a hook to console.log() or otherwise check that a message has been written to the console, or any other suggestions on how to write the test case? console.log doesn't keep a record of messages that are logged, or emit any events that you could listen for. It's not possible for your tests to directly verify its output from JavaScript. Instead,

Does C1 code coverage analysis exist for Ruby? [closed]

笑着哭i 提交于 2019-11-30 07:08:36
I'm currently using Rcov to get C0 code coverage analysis for a rails project that I'm working on. However, those results are practically meaningless- I have 100% coverage according to rcov (as it only covers C0 analysis) and I've barely written half the test cases for the functionality that exists thus far. I'm used to the useful results from the code coverage in Visual Studio 2008 Team, which has C1 coverage. Are there any tools that provide similar coverage for ruby? At the moment, there are no C1 coverage tools for Ruby. In fact, there aren't any coverage tools other than RCov. Until

Should I practice “mockist” or “classical” TDD?

依然范特西╮ 提交于 2019-11-30 06:19:10
问题 I've read (and re-read) Martin Fowler's Mocks Aren't Stubs. In it, he defines two different approaches to TDD: "Classical" and "Mockist". He attempts to answer the question "So should I be a classicist or a mockist?", but he admits that he has never tried mockist TDD on "anything more than toys." So I thought I'd ask the question here. Good answers may repeat Fowler's arguments (but hopefully more clearly) or add arguments that he didn't think of or that others have come up with since Fowler