Tagged Questions
Unit testing is a method by which individual units of source code are tested to determine if they are fit for use.
7
votes
1answer
48 views
Unit test for Unique Position Point
Here is one of my msTest Unit Tests and possibly one of the worst "looking" tests.
...
-1
votes
0answers
16 views
How to refactor code that violates the Law of Demeter without too much hassle? [on hold]
I'm facing a little problem regarding a piece of legacy code I'm working with and trying to make it Unit testable. Here's the chunk of it:
...
5
votes
1answer
53 views
+200
Unit testing a click event with asynchronous content
I'm writing unit tests for a web application that has quite a lot of UI interactions. I would like some feedback regarding on how to handle click events with asynchronous code.
My goal here is to ...
0
votes
0answers
15 views
How to unit test this method (write a UIImage to disk) [closed]
So I have this method in a class which writes an image to disk. How can I unit test it?
...
4
votes
1answer
41 views
Unit Testing Bejeweled Wilds
I created a pretty complex algorithm for calculating matches on a Bejeweled board that kept track of matches involving wilds. After doing some in-game testing, I found quite a few bugs that needed to ...
5
votes
2answers
115 views
Stack data structure unit testing
I have this contract:
public interface Stack<T> {
void push(T object);
T pop();
int size();
}
I am curious what you think about my test of the ...
1
vote
1answer
50 views
Calculating Euclidean distance and performing unit-testing
The method creates a link, an edge between two nodes, and calculates the Euclidean distance.
I'm testing that after linking, the link does indeed exist, and that the distance is correct.
I've used ...
2
votes
2answers
62 views
Require config file in class
I want to use the variables that have been declared in a config.php file in a class for testing. I am not sure if this is the right way like I have done it.
I have a configuration file, config.php:
...
0
votes
0answers
23 views
New to code reviews. How to approach from a software test engineer perspective? [migrated]
I may be expected to perform code reviews in what'll likely be Java. The thing is, I'm a software test engineer. I've never been a developer nor programmer. I've always thought another developer would ...
4
votes
1answer
55 views
TDD and use case: cook dish with substitutions
This is code for a class that takes available ingredients and returns left over ingredients after making a dish.
Cesars: 2 carrot 4 ice burg 1 chicken 1 beans
Russian: 2 carrots 2 beans 2 chicken
...
2
votes
1answer
68 views
UnitTesting: Is this TestCase overkill?
Is this Test Case overkill?
I am new to Unit Testing so I am learning and I'd love to hear your opinion about it.
...
0
votes
0answers
28 views
Designing entities, use cases and repository
I'm developing an Android application which would remotely connect to an insurance database and perform some basic CRUD operations and I'd like to learn how to keep clean app's architecture from ...
5
votes
0answers
59 views
Mucheck - a mutation analysis tool for Haskell programs
We have been working on a mutation analysis tool for Haskell tests called MuCheck. It accepts any Haskell source file, and a function name to mutate, applies a defined set of mutation operators on it, ...
4
votes
2answers
77 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 ...
4
votes
1answer
40 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
47 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.
...
9
votes
2answers
86 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
64 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 ...
14
votes
4answers
921 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
101 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 ...
2
votes
1answer
20 views
1
vote
0answers
17 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
42 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
78 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
42 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
95 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
55 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 ...
3
votes
0answers
36 views
0
votes
1answer
66 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
46 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
62 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
316 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
84 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
91 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
72 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
55 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
102 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
40 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
68 views
4
votes
1answer
133 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
93 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
43 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
29 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
143 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 ...
4
votes
1answer
46 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
33 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
125 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
209 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 ...