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

3
votes
1answer
33 views

Unit testing a servlet in a meaningful way

I have to write a unit test for the method processRequest in the servlet below and I'm wondering if: It just shouldn't be done. The class should be rewritten / ...
8
votes
3answers
79 views

Automagic testing framework for VBA

Building on @RubberDuck's recommendations, I now have something I find... beautiful. I'm sure there's a couple of things left to polish - this site is about making great code out of good any code, ...
3
votes
1answer
66 views

Creation of a temp file on Windows

I implemented a test that reads data from temp file on Windows. I originally had an issue that I solved with the help of this answer ...
6
votes
1answer
57 views

A hacked-up testing framework

Inspired by this post, I wanted to be able, in any vba project I could be working on, to create a test class and write test methods. Like this: ThisWorkbook Workbook | class module (client code) ...
9
votes
1answer
76 views

Unit Testing in VBA

Unit testing in VBA is... lacking. (What isn't lacking in VBA though?) Since I've become more interested in unit testing lately, I decided I needed something better than ...
-2
votes
1answer
39 views

Forgetting about test method naming conventions with xUnit.net and DisplayName [closed]

I have been looking into migrating my tests from NUnit to xUnit.NET, and one of the features I really like is the [Fact(DisplayName="...")] attribute, that ...
3
votes
1answer
30 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 ...
8
votes
2answers
85 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 ...
3
votes
1answer
89 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 ...
1
vote
0answers
28 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 ...
7
votes
5answers
446 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
65 views

Using a factory class for TextWriter than can be stubbed/mocked

This is my factory class: ...
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 ...
3
votes
0answers
52 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 ...
2
votes
1answer
35 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? ...
3
votes
2answers
64 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). ...
8
votes
6answers
860 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: ...
5
votes
1answer
46 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 ...
0
votes
0answers
65 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
118 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 ...
1
vote
1answer
30 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 ...
8
votes
2answers
150 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 ...
10
votes
2answers
212 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 ...
6
votes
3answers
422 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 ...
5
votes
2answers
103 views

Concerns about my repository implementation

I have a repository called PostsRepository: ...
4
votes
1answer
48 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: ...
7
votes
2answers
161 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). ...
12
votes
4answers
540 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 ...
4
votes
2answers
74 views
13
votes
1answer
139 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
71 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 ...
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 ...
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 ...
5
votes
2answers
164 views
1
vote
1answer
68 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
87 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
129 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
169 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
92 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
49 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
255 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
45 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
118 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
91 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
81 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, ...
0
votes
1answer
52 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
594 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
90 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
245 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: ...