Unit testing is a method by which individual units of source code are tested to determine if they are fit for use.
2
votes
1answer
21 views
Designing unit tests for paramiko wrapper
Before I get to the question, let me note that I'm a trained scientist, not a programmer; I've done my best to self-teach what I've needed to know so far, but in the interest of making my code usable ...
4
votes
1answer
84 views
Fizzbuzz in Python
I'm new to Python and wondering what can be improved with the following super novice program - in terms of the solution and code style etc.
test_fizzbuzz.py
...
1
vote
0answers
27 views
Testing input validation and an AJAX request with Javascript and QUnit
I have a simple web page. The user enters the name and rank of a soldier and hits submit. If the input is invalid, an appropriate error message gets displayed. Otherwise, it adds the soldier to a ...
2
votes
1answer
29 views
Implement test which tries function with diferent params and expected results
What could I improve in the following code? The goal is to test a function againts a table of input parameters and compare to some expected results with some tolerance (as there are random variables ...
2
votes
1answer
49 views
Sudoku validator
I've decided to learn some more Haskell writing a Sudoku validator, the function checkSudoku outputs True if the Sudoku is valid and False if it is not. I did not ...
3
votes
2answers
52 views
Radix sort with integer divisions
Here's a perhaps naive but simple implementation of Radix sort in Java.
It works with any radix, and both positive and negative numbers.
...
0
votes
1answer
28 views
Testing a UI related revealing module [closed]
When I write my JavaScript modules I tend to keep a lot of methods private in an IIFE. A simplified example below:
...
3
votes
2answers
48 views
Titleize words in a sentence but with some conditions
Below is the code I have written to capitalize all the words of a sentence except if
The words belong to the littleWords list.
The word would be capitalized if it's the first word of the sentence ...
1
vote
1answer
24 views
7
votes
2answers
321 views
Unit Testing Search and Sort method(s)
I just decided to write a unit test, and see how to do it. This is my unit test:
...
2
votes
0answers
28 views
Tested cartesian plane utility
I am starting to explore automated testing of code, so I decided to write some trivial code about the cartesian plane and test it. I am particularly interested in automated testing conventions and ...
0
votes
2answers
31 views
Testing a simple guard clause in isolation
I’m using decorator objects in a Rails app so that I don’t have to do nil? checks in views. Everything is working nicely and it’s easy to test, but I’m suspicious ...
7
votes
1answer
56 views
Unit test for Unique Position Point
Here is one of my msTest Unit Tests and possibly one of the worst "looking" tests.
...
5
votes
1answer
99 views
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 ...
4
votes
1answer
50 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
123 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
61 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
70 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:
...
4
votes
1answer
62 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
90 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
36 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
62 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
84 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
43 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
55 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.
...
10
votes
2answers
96 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
67 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
940 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
104 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
19 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
45 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
105 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 ?
...
1
vote
0answers
46 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 (...
4
votes
3answers
100 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
62 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
38 views
0
votes
1answer
67 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
32 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
51 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
71 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
317 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
88 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.
...
6
votes
0answers
104 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
119 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
1answer
74 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
119 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
44 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
74 views