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
1answer
94 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 ...
0
votes
1answer
62 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 ...
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 ...
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 ...
5
votes
2answers
149 views
1
vote
1answer
33 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
39 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
63 views

Verifying the type of an AggregateException's inner exception in a unit test

I've got the following code inside an integration test. ...
6
votes
2answers
143 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 ...
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 ...
2
votes
1answer
46 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
98 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 ...
6
votes
1answer
42 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: ...
5
votes
2answers
66 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
74 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, ...
1
vote
1answer
32 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 ...
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
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 ...
6
votes
2answers
217 views

Create better Unit test

Question: Is there anything you could do in order to improve the test? I am using Spring Framework 4, Hibernate 4, JUnit 4. All DAO unit tests inherit from TestDaoSetup class: ...
7
votes
2answers
92 views

Test string if numeric

I want to implement the following function: ...
4
votes
1answer
62 views

Loop cleanly through different classes

If I have a number of different classes which manage certain tests. At the moment I have to launch each test individually which results in a lot of if statements. ...
10
votes
2answers
104 views

Unit tests for an argument-checking class

I am wondering if my current unit tests could be written better, I am most interested in whether it is possible to make the code look more concise, as currently it a boiler-plated mess. I have full ...
15
votes
3answers
477 views

Writing better JUnit tests

I am using Spring Framework, Hibernate and JUnit. I am testing persisting of a UserEntity. The UserEntity has the following associations: ManyToMany - City ManyToMany - ActivityCategory ManyToOne ...
10
votes
1answer
184 views

Markup calculator application using MVC

I want to make sure that the code is correct in terms of its design, code correctness, best practices & Junit testing. The complete description is given below: Functioning of the app quickly ...
12
votes
3answers
228 views

Trading Card Game's Hand class and tests

As part of a Trading Card Game, I have created a Hand that will need to hold all cards that a player currently has in his hand. The code is built using Java 8. The ...
10
votes
1answer
128 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 ...
3
votes
1answer
86 views

Unnecessary unit test?

I have this method in my service layer ...
7
votes
3answers
134 views

Unit tests: to cast or not to cast?

Suppose the following example unit test for an ASP.NET MVC controller: ...
4
votes
2answers
71 views

Server side validations and unit testing in MVP

We are following passive controller approach and when user clicks on submit, server side validations are fired. There are many other fields on the screen that needs to be validated. I would like to ...
3
votes
1answer
151 views

Testing async API calls using Jasmine 2.0

I'm upgrading my project from YouTube's V2 API to their V3 API. I'm also taking the time to upgrade to Jasmine 2.0 since I already need to look at my test cases. Here's a couple of test cases and the ...
10
votes
4answers
322 views

Schedule class (exercise for test driven development)

Schedule is a simple class that could be used in program to manage when a task should be repeated (a todo list, for example). Its constructor requires a start date and an optional end date. Then type ...
4
votes
1answer
41 views

Ranking a variant array with variable dimensions

I'm doing VBA macros and need to use Arrays of values extensively. After the below help from @TonyDallimore in StackOverflow, I've decided to use nested variant arrays. VBA chrashes when trying to ...
7
votes
3answers
166 views

Refactoring method to make it unit testing friendly

I have a completed application which I'm trying to write unit tests for (Yeah I know, talk about bad practices) I have the following class here ...
4
votes
1answer
117 views

Am I over-engineering?

So I just jumped to a new project, which uses activerecord pattern. It's a subscription service website. I have the following User object that extends a framework specific ORM object. ...
11
votes
3answers
1k views

Sudoku Solver: what are good ways to avoid the deepcopy?

In an effort to teach myself some python and programming in general I made a Sudoku Solver (as many others have done before me from what I can tell). The one thing that bugs me a little is my use of ...
0
votes
2answers
108 views

Unit Testing Datalayer written in ADO.net

I have datalayer code as below which is implementing an interface as: Note: I have hand written this code on Notepad so it may contain some typo errors, which you can gracefully ignore. I am ...
10
votes
2answers
331 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 ...
10
votes
1answer
133 views

Do my unit tests follow best practices?

I've watched quite a few videos and read a couple of articles on unit testing and I've tried my best to make this test case as good as possible. In which areas can it still be improved? I should ...
3
votes
1answer
275 views

Unit tests using C#, Moq, AutoFixture, FluentAssertions

Could you give any suggestion on the following unit tests? How to make it more readable, maintainable and trustworthy. If it is not a problem - post some code with the suggestions. ...
5
votes
2answers
84 views

First time BDD: Testing the same things in both acceptance and unit tests

I just tried BDD for the first time and implemented a simple Semantic Versioning Bumper in Python. The class takes a version string in the format of major.minor.patch (i.e. 3.2.2, where major=3, ...
1
vote
1answer
102 views

Structuring unit tests

I have settled with this type of structuring of unit tests. Basic idea is that there is a base test class for the tested class, and a subclass for every tested method. They use the mocks and ...
5
votes
2answers
119 views

Implement strtod parsing

In this comment the OP wrote, I am a newbie so i would like to know how would i parse the negetive numbers/arguments ? In this answer @200_success showed an implementation using the strtod ...
1
vote
1answer
220 views

Unit testing - test class inheritance vs single test class [closed]

Which unit testing approach and WHY do you prefer? Inheritance-driven-testing ...
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 ...
3
votes
2answers
142 views

My first model RSpec

This is my first model RSpec test: ...
6
votes
2answers
117 views

Create and destroy object in Unit Test

I have some doubt when I should create an object in an Unit Test when the object needs to be stopped cleanly. Usecase: I have a class ComplexClass which has 3 functions: Start(): starts a Thread ...
10
votes
1answer
436 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 ...
3
votes
2answers
108 views

Read Lines From IIS Log

The purpose of this class is to read an IIS log (or multiple ones). One thing to note is that the columns can differ based on settings in IIS. So a couple of concerns that I have: Is The ILogReader ...