Unit testing is a method by which individual units of source code are tested to determine if they are fit for use.
3
votes
3answers
76 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
50 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
28 views
0
votes
0answers
31 views
Haskell Pure Fixed Length Queue
I am modeling an infectious disease with an fixed incubation period. I choose a queue to keep track of when people will become symptomatic. I imagined using some operations like so:
...
2
votes
1answer
53 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 ...
1
vote
0answers
22 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
31 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
25 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
309 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
74 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.
...
4
votes
0answers
54 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
35 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
45 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
70 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
28 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
61 views
4
votes
1answer
126 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 ...
7
votes
1answer
57 views
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
40 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
27 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
65 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
43 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
23 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
94 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
120 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
165 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
165 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
132 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
89 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
164 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
90 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
65 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
137 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
45 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
94 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
130 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
134 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
450 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 ...
-1
votes
4answers
27 views
How can i refactor this test?
I'd like to refactor my extractSimplePromptName 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
100 views
5
votes
1answer
100 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
49 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
72 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
873 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
2answers
87 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 ...
3
votes
1answer
130 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
142 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
33 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
443 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 ...
11
votes
2answers
237 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 ...