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
2answers
51 views

Credit card checking

I am practicing test-driven development in Python. Feedback about both the tests and the code is appreciated. I'm using luhn algorithm and regex to check credit card numbers for validity. Here are ...
2
votes
2answers
25 views

Test many sorting algorithms using Python and Nose

I'm trying to learn how to build a good test suite, using simple sorting as an example. Particularly, I am using Nose to generate all the tests based on a simple list of lists, where each sublist is a ...
3
votes
1answer
30 views

Filtering with multiple inclusion and exclusion patterns

I have a requirement to be able to filter a list of strings by both inclusion and exclusion patterns (using fnmatch-style wildcards), of which there can be many. ...
7
votes
0answers
33 views

Karate Chop Kata

I had some time to kill today, and I found the Karate Chop Kata. Specification: Write a binary chop method that takes an integer search target and a sorted array of integers. It should ...
10
votes
1answer
48 views

Even more extensible and testable BuzzFizz

Inspired by Extensible and testable FizzBuzz I have decided to write my own implementation, partially based on my own answer and on the other answers. First a warning to all of you: Never make such ...
13
votes
4answers
838 views

Extensible and testable FizzBuzz

There seem no end to fizzbuzz implementations. Something I rarely see is an implementation that's easy to extend with more name-divisor pairs. Another thing that usually annoys me is the lack of ...
14
votes
2answers
90 views

Playing with strings

I wanted to dust off my C skills, so I decided to write a couple string manipulation functions. I aimed for simplicity and safety. Performance was not a concern. Please be a thorough as you like. C ...
1
vote
0answers
14 views

Filesystem-dependant unit-testing in go

I recently rewrote a piece of software to practice unit-testing. I decided to constrain myself and do dependency-free code, so I can do better and easier tests. I came to the following solution while ...
4
votes
2answers
36 views

Addressing possible strategic problems with LDAP module and unit testing code

I'm a sysadmin writing a tool to perform administrative tasks on our upcoming new account management system that runs over LDAP. I want the tool to be highly flexible, configurable, and reliable, so ...
3
votes
1answer
56 views

Testable authentication handler for web API

I need to unit test my authentication handler. I don't really want do an assert against the text message returned by the handler. How could this be improved ? ...
0
votes
0answers
37 views

Testing with multiple input datasets and expectations

I wanted to make 3 test suites where each would run a test class with a specific input. I figured that in order to do this I could: Make an abstract test suite with all the variable parts (...
3
votes
3answers
91 views

Customer contact unit-testing

I'm dealing with a damn scary function which I would wish to refactor so I could unit test it properly and improve the design. I will try to explain what it does and how it works in detail (with ...
2
votes
1answer
52 views

Prefer simplicity over testability? [closed]

Currently I try to create some unit tests for a project, which provides access to some webservice methods. It's interface is rather simple. I have a class "WebService" which offers methods like ...
2
votes
0answers
32 views

Simple spec testing DSL

I wrote a very small little DSL for spec testing: ...
0
votes
1answer
61 views

Pure fixed length queue

I am modeling an infectious disease with a fixed incubation period. I chose a queue to keep track of when people become symptomatic. I imagined using some operations like so: ...
4
votes
1answer
66 views

Motor degree movement function

I want to control a motor which rotates a device over a gear. Input values for the device are from 0 to 360 degrees. The motor should always rotate the device the shorter way around. For example, if ...
2
votes
0answers
31 views

Is monkeypatching __builtin__ in tests like this an absurdly complicated practice?

My hunch: Probably. I'm testing a little magic behaviour of my script that automatically reads from ~/.ghtoken to do automagic authentication on GitHub API ...
3
votes
1answer
43 views

Rename files to titlecased

I wrote this Python script to rename specified files to "titlecase", for example: hello.txt to Hello.txt ...
2
votes
0answers
40 views

Jasmine Unit tests for simple toggle class

Using Javascript/jQuery I created simple toggle and started writing unit tests for it using Jasmine. Am not sure however if I should be testing for things like e.g. ...
8
votes
3answers
315 views

The stripping extensions

In order to make my life easier with parsing some VBA code, I have written a few extension methods to extend the string type, and put them in this ...
4
votes
3answers
83 views

Unit Testing for a Complex Game

I have known about unit testing for a while now, but I am just now finally understanding how to implement it. I think that my initial implementation is a little rough so I could use some feedback. ...
5
votes
0answers
74 views

Minimal C++ Unit Test Framework

I've written a minimal unit test framework. The goal was to allow assertions of booleans, for equality and catched exceptions. Two things are bugging the most. That assertions have to rely on macros ...
1
vote
1answer
44 views

Add existing models to a relation using nested attributes

I needed to add existing models to a has-many relation using nested attributes so I overwrote thumbnails_attributes=: ...
6
votes
0answers
50 views

(Yet Another) Conway's Game of Life in Haskell (Naive)

I code Haskell as a hobbyist. I'm interested in feedback on my naive implementation of Conway's Game of Life. Specifically, as stated in the Quick Tour of the website, I am interested in: Best ...
3
votes
0answers
84 views

Laravel Testing: Is this testing too much of the inner workings?

So I'm using laravel for a project and have a InvoiceRepository and a InvoiceRepositoryTest and I have written the test first ...
2
votes
1answer
38 views

Mixing Watir::Browser into RSpec

In my previous Watir question I was making a module with session_FF accepting a block. Now I want to make the same but via RSpec. Here is my try: ...
4
votes
1answer
65 views

Test with array and mock

Here is my function I want to test: ...
4
votes
1answer
129 views

Sum of numbers which are not sum of two abundant numbers

The following program is a solution to Project Euler Problem 23. That problem defines an abundant number to be one whose sum of proper divisors is greater than it, tells us that all integers at least ...
8
votes
1answer
85 views
+100

Unit testing annotation processors in Java

I'm working on a micro-benchmarking framework in Java. To give you some context, this is how it will work: Given multiple implementations of some algorithm, and you want to compare which one ...
1
vote
1answer
41 views

Orange Tree simulator

I'm practicing SOLID principles and the concept of making a clear distinction between an object's private and public interfaces. ...
2
votes
1answer
28 views

Isolating testable portions in rendered html, without imposing on content or formatting

I'm unit testing some webpages and I'm trying to figure out how to best isolate the portions that need to be tested. There are two goals: Don't impose on the webpage's content or format, and be as ...
1
vote
1answer
94 views

Testing after_save hooks in Rails 4.2 with MiniTest

I've recently started working on a new application in Rails 4.2.0-beta2. I've been using this as an opportunity to learn more about MiniTest, with a stretch goal of being as strict with myself with ...
3
votes
1answer
45 views

Unit testing a bash script manipulating the working directory path

bd is a bash script to conveniently jump multiple directory levels up from the current working directory instead of a tedious and possibly inaccurate ...
3
votes
1answer
30 views

Unittests for CashFlow object

I'm just writing a small unittest to test for a hypothetical library and object, as a way of predefining the behavior, perhaps both as an acceptance test and for unittesting as well. As I'm writing ...
0
votes
2answers
108 views

How to write unit test cases for any real time Java app? [closed]

With lack of real time experience in developing a Java application, I would like to understand the testing strategy for any written module made of multiple classes. Below is the sample application ...
4
votes
1answer
146 views

Dependency Injection into an Abstract Class

Me and another developer have recently forked and taken over an abandoned, open-source project. I have also been reading articles and watching videos by Misko Hevery. When I was reading through the ...
8
votes
4answers
200 views

Align Strings for Output

I wrote a class which can format input so that it is properly aligned. I'm interested in all suggestions (regarding structure, usability, style, naming, comments, etc). I'm especially wondering ...
10
votes
2answers
169 views

LogManager Tests

I should have started with this code. I wrote my logging API without writing unit tests, and since I recently wrote an automagic unit testing API I though I might as well go ahead and use it. So I ...
8
votes
2answers
141 views

Unit Testing - A Better Solution

Following-up on the Automagic testing framework for VBA review, I've refactored much of the TestEngine static class, and introduced a ...
4
votes
3answers
131 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 / ...
12
votes
5answers
183 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
104 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
69 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) ...
10
votes
1answer
153 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 ...
3
votes
1answer
52 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
95 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
142 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
1answer
197 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
452 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 ...