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

7
votes
2answers
70 views

How to decouple tests from implementation and increase their resilience?

I have read on numerous occasions that tests should not be coupled to implementation details - this makes perfect sense. Now I am having some trouble decoupling my tests from implementation details ...
2
votes
1answer
19 views

Unit testing Backbone Model

I would like to hear other people's opinion on how I unit tested a functionality in a Backbone Model. As you see below, the code under test, upon being called to toggle, toggles its completed state ...
6
votes
1answer
4k views

Hypothetical SalesTax challenge

I have a small solution to the following hypothetical problem: Basic sales tax is applicable at a rate of 10% on all goods, except books, food, and medical products that are exempt. Import duty ...
4
votes
1answer
67 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 ...
3
votes
1answer
53 views

Make a testable DAL using service and repository pattern

I'm implementing a Web API that communicates with old WCF services and want to make it future proof. The Web API consists of: API controllers Service Providers Repositories I've implemented a ...
0
votes
0answers
19 views

Unit Testing of Curl based Rest Client Library

https://github.com/andrewjwolf/payjunction-php I ran into some issues with unit testing in that getting the response body etc from the curl handle was tricky. I didn't want to necessarily use a mock ...
6
votes
5answers
430 views

Refactoring String manipulating method with TDD

I'd like to refactor my extractSimplePromptName test so it does the same but it's "prettier", hence less code. As far as looking at it, it seems like it could be ...
4
votes
1answer
58 views
7
votes
2answers
152 views

Single class unit test framework in Java

This is a single class and dependency free1 unit test framework for Java. The only assertion available is assertTrue (this can be used for all test cases). ...
0
votes
0answers
18 views

Unit tests: avoiding overspecification [migrated]

Say I have the following method that sends emails. I know I should have tests for the different status codes returned. I am also testing if the the methods CreateMail() and Send() are being called. I ...
2
votes
0answers
46 views

What should I test about a controller that uses a tested repository (or service)?

I have a repository called PostsRepository who implements an interface called IPostsRepository ...
8
votes
6answers
856 views

Is it possible to optimize the following boolean checks?

The following code works and it prints out only True as it is supposed to, for all the different cases: ...
3
votes
2answers
61 views

Create nice url with diactrics removal

Please review my class. It uses iconv() (it's probably not the best solution however I haven't found any better alternative to change unknown characters). ...
1
vote
1answer
29 views

Helper Method for Generating Stubbed ICommand in Rhino Mocks

This helper method is designed to make stubbing ICommands simpler. Do you see any problems with this implementation? ...
0
votes
1answer
48 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 ...
5
votes
2answers
43 views

Map reduce tester ported from bash to Python

My MapReduce tester is clearly ported from Shell, short of args=None for line in args or read_input(), what's a better way of ...
9
votes
2answers
205 views

Concerns about the correctness of my Repository and Controller tests

Lately I have been researching how to best unit test an EF repository and given a properly tested repository, what to test in the controller. My research did not reveal many sound examples or ...
5
votes
2answers
430 views

Reading and parsing CSV files

This is my first real attempt at a Scala program. I come from a predominantly Java background, so I'd like to know if the program sticks to Scala conventions well. Is it well readable or should it ...
0
votes
0answers
61 views

Mock user table class

I've just created my first tests using mock classes. So far my tests are running much faster and now I guess I'm solely focusing on a single class (in this case I'm testing UserTable and mocking the ...
4
votes
2answers
105 views

My first model test in PHPUnit

I've just created a test to create my table gateway class. I've written about 8 tests and all are passing. I'm hoping anyone can offer any advice on what to do next to make these better. This is quite ...
8
votes
2answers
127 views

Bowling game scorer

I was given a simple coding exercise as part of a job interview process, for which I received a negative review. This is the question: DiUS is starting a bowling club. To help with the club, we ...
1
vote
1answer
29 views

Is building a test instance from a mix of both mock and real objects OK?

I am new to android testing and would like to try start off in the correct direction, so I am trying to understand if this is the correct way to test a particular method or if there is some best ...
25
votes
10answers
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 ...
6
votes
3answers
418 views

DRYing out some Java code and tests

I am writing some tests that all follow the same pattern, I feel like repeating myself over and over again, how can I reduce the repetition? The (almost) repeating part is in constructor and the class ...
4
votes
1answer
45 views

Using quickCheck for “99 Haskell problems” - problem 1

I'm working on learning Haskell, and I've implemented a solution to the first of the 99 Haskell problems. Here is my code: ...
6
votes
2answers
95 views
2
votes
1answer
177 views
5
votes
2answers
96 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 ...
8
votes
2answers
856 views

32-bit counter and test bench

How could this VHDL counter and its test bench be improved? I am interested in anything you see that could be done better, but especially in the test bench: Is ...
12
votes
4answers
534 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
291 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
197 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
3k 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
203 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
140 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
133 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 ...
7
votes
1answer
350 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 ...
4
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
229 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 ...
0
votes
1answer
68 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
36 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
146 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
48 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
45 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 ...
10
votes
2answers
386 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
54 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
62 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
103 views