Unit testing is a method by which individual units of source code are tested to determine if they are fit for use.

learn more… | top users | synonyms

12
votes
4answers
506 views

Unit Testing for isPrime function

I've decided that I want to take a stab at test first programming. So, before I tackled writing an isPrime function, I wrote this unit test. It's my first and I'm ...
3
votes
1answer
248 views

Where to put common method used in controllers that calls service layer?

I have an ASP.NET MVC 5 web application using the repository pattern, and I have several controllers that need to call my _loggingService (queries audit logs) to ...
7
votes
2answers
188 views

Does this FizzBuzz code correctly follow SRP and unit-testing?

This is code for FizzBuzz. I have also hosted in on my GitHub. FizzChecker Tests ...
3
votes
1answer
2k views

Unit testing code that calls RESTful API

I'm writing a library which calls a RESTful API and then performs some work on the data. I've architected my code like this: I have a class (let's call it ...
5
votes
1answer
200 views

Wrapping a telephony RESTful service for sending text messages and making phone calls

So I'm writing an abstraction layer that wraps a telephony RESTful service for sending text messages and making phone calls. I should build this in such a way that the low-level provider, in this case ...
10
votes
1answer
130 views

Automatically run doctest every time program is run

I would like this to happen every time I run a program from the command line. Is my approach Pythonic? I'm interested to know whether there is any problem with readability or correctness. Any general ...
13
votes
1answer
120 views

How can I better name my tests?

I am relatively new to TDD and am trying to adopt better names for my tests. I wrote the following tests abruptly and have since refactored them to the best of my ability, but despite my best ...
1
vote
1answer
34 views

Testing individual nodes launched by naught using supertest

The purpose: an express node.js server which can be launched using naught, with an integration test using supertest. Each worker naught runs will test itself on a unique port, and only if passes it ...
7
votes
1answer
342 views

Timing analysis of many test cases in Python

I am learning about timing analysis in Python. I used time module before it was pointed out that timeit module would be better ...
3
votes
3answers
2k views

Make WCF Service testable

I have WCF Service. It works fine and I want to have test coverage for it. Unit tests and acceptance. The problem is the static class in the code. How is it ...
2
votes
0answers
203 views

Testing Scala code which depends on objects

I am writing a small oauth2 library for Play! 2.1 scala. As I am still learning I got stuck trying to TDD and ended up writing the code first, then refactoring for testability. By testability I mean ...
23
votes
9answers
3k views

What are some indicators that I was over-thinking my solution to this problem?

This question is a cross between career question and a code review. I was uncertain where to ask, but since there is code involved I went with CodeReview. I’m going through the process of technical ...
0
votes
1answer
66 views

Command line multipart or single file downloader

I am looking for a code review for this multipart or single file chunk downloader using threading and queues. downloader.py ...
4
votes
1answer
33 views

Catch-style unit testing in JavaScript (phase 2)

Continued from phase 1; please read it first for background. Overview This phase focuses on assertions. Here's where things get ugly. Catch uses macro expansions to decompose assertion ...
0
votes
1answer
141 views

Unit testing where you depend on implementation of another method [closed]

I am implementing a gap buffer and am trying to write a test for the insert method, the test currently looks something like this: ...
2
votes
1answer
47 views

Unit-testing account transaction code

I'm playing with unit-testing in Ruby. There is a situation that I don't know if is good enough or if I am doing the wrong abstraction. I have two classes: ...
7
votes
1answer
44 views

Catch-style unit testing in JavaScript (phase 1)

I decided to port my favorite unit testing framework, Catch, to JavaScript. So far I'm focusing on test cases and sections. I'll add assertions in phase 2, and output in phase 3. The goal for this ...
3
votes
0answers
50 views

CppUnit test suite for testing a routine

I wrote a CppUnit test suite to unit-test the code that I posted here which is a single routine that proposes how a Lua expression could be auto-completed. What do you think? I appreciate all the ...
10
votes
2answers
342 views

Using a Pythonesque range() generator function with the Java foreach loop

Now that we have the nice new foreach loop in Java, the old-style loop looks ugly be comparison. I like the way Python has a ...
1
vote
1answer
38 views

State and Interaction based testing using jMockIt

I am new to jMockIt and so wanted to learn it. I thought of implementing a synonym servlet kata. The servlet takes a word as input and returns the synoyms of the words as a comma seperated string. The ...
4
votes
1answer
41 views

Ugly code unit testing with PHPUnit and Doctrine2 (an ORM)

I am trying to unit test a small class that I consider part of the "business-logic" layer of my project. It mostly just interact's with Doctrine's entity manager and a couple of entities with a ...
5
votes
1answer
67 views
6
votes
2answers
146 views

Testing quicksort user input

I am testing a quicksort implementation. Arrays of random size with random data are passed to quicksort and the return time is averaged out. The user is prompted to enter values for minimum length ...
3
votes
2answers
588 views

This TDD code seems noisy

This is my very-first-ever run at TDD. How did I do? In keeping with Uncle Bob's Three Rules, I wrote every test first, starting in order from the top down as you see here (below). Here's the ...
5
votes
2answers
89 views

Unit Testing an AppInfo class

I have never written a unit test and I am really new to C#. I am attempting to test a method, am I testing for the right things here? The Method ...
6
votes
1answer
44 views

FuseMonsterAction implementation and unit tests

I'd like to get a general review on the following code, and I'll highlight an extra point below: ...
18
votes
4answers
2k views

Just a lowly counter that turned out to be surprisingly complicated

While writing this review, I saw a need for a Counter object similar to Python's. It seemed like it would be easy to write such a class, but it turned out to be ...
7
votes
1answer
104 views

JUnit extending abstract test class

I have been thinking quite some time and asked an StackOverflow question about extending abstract test classes, but I haven't been able to do it until now. I'll list my approach and then discuss some ...
5
votes
2answers
71 views

Using the builder pattern to build mock objects and nested builders

No, this question has no roosting construction workers. I'm not sure if what I'm doing is a good use of the builder pattern or whether its a bastardization of what its intended purpose was. I'm ...
4
votes
2answers
240 views

Does my code need refactoring before adding unit tests?

I have this code that works fine, but I would like to create some unit test for this class. Most of the code is in private or ...
4
votes
2answers
78 views

Using shims to turn my integration tests into unit tests

I want to understand how to properly unit test a function such as this. The function doesn't return anything, but it does call other functions that themselves have already been unit tested. My ...
3
votes
1answer
71 views

Python Best Practices - File Validation and Unit Testing

I just started a new project which reads in a video file and splits it up into frames. I started by just throwing everything in the GUI, but decided I wanted to make this a more well designed program, ...
2
votes
1answer
3k views
3
votes
1answer
243 views

Modelview programming in PyQt4

In my first attempt, I have tried to load images from disk and load it to a QTableView using QAbstractTableModel. I'd like a ...
5
votes
1answer
84 views

Hard-to-test 3 Tier Architecture

I'm having trouble testing some code. It's laid out in such a way that the business logic relies on the persistence layer. Some classes require that an object be saved to a database. Some classes ...
10
votes
1answer
465 views

Writing and reading of a custom binary protocol

I'm currently trying to develop some code that will handle parsing and building of a custom binary protocol. The protocol itself is still fairly fluid but the basic core features are decided. These ...
6
votes
2answers
488 views

Simple calculator for an interview

Question: Simple Calculator Input loaded from file. Instructions can be any binary operators. Ignore math precedence. Last input is apply and a number e.g. "apply 5". Calc is then ...
11
votes
3answers
1k views

Can these unit tests be improved?

I'm not the greatest at writing tests yet and I'm starting a new OSS project for learning and as part of it I want to tackle being more effective at writing tests, more specifically quality tests. I ...
21
votes
3answers
1k views

Code indentation for declaring inputs/outputs in an array

I'm writing a list of inputs and outputs for to be compared in unit tests. ...
16
votes
3answers
745 views

Rainfall Problem

About a year ago when I was applying to jobs for the first time, I had an interview at a company and they posed the following problem to me, which I preceded to bomb. A year later I actually came up ...
4
votes
1answer
121 views

Simple class to represent progress

Progress class was written using TDD. Interface of this class (pseudo-code): ...
3
votes
1answer
126 views

Partial data reading implementation

I'm trying to learn Python and am working on a simple Tiled Map Format (.tmx) reader as practice. So as to not post too much code at once, I'm only publishing the ...
6
votes
3answers
347 views

Class that represents an instant in Time

Please review my code and let me know of any additions or modifications that would make this even more useable. The initial idea was to create a simple Time class that has only one function: To ...
3
votes
4answers
375 views

Complexity in multiple if-else algorithms

I am learning Algorithms, Part I on coursera.org. I just watched the first lecture then tried to write some code in C#. The class basically stores list of connected numbers. You can add numbers that ...
4
votes
2answers
153 views

Singly-linked list library

This is sort of a follow-up to a post I created about 10 days ago, but I have completed the implementation: Designing function prototypes for a singly-linked list API in C. As I began to work on the ...
5
votes
1answer
357 views

Sqrt (square root) function

As an exercise in learning Scala, I implemented a square root function like this: ...
3
votes
1answer
95 views

XML schema for Database Unit Tests

I am attempting to develop an XML schema (XSD) to represent a set of unit tests for some code. (Specifically, I am testing Oracle PL/SQL stored procedures.) I would like to have something that ...
5
votes
1answer
247 views

Kata: Natural Sort

I am choosing to learn F# for my own enjoyment. I am getting to the point where concepts of F# seem to be pretty easy, but understanding some of the whys and whens is a bit harder. Before I get into ...