Unit testing is a method by which individual units of source code are tested to determine if they are fit for use.
1
vote
1answer
27 views
Unit test with check testing framework
I have some code where the purpose is the decide if a char is between quotes in an expression. For example, awk '{print $1}' has a ...
2
votes
1answer
57 views
Check binary tree symmetry by reversing, checking equality, coverage tested, makefile
A few weeks ago I recall a HackerNews story (found it again: "I Don't Want to Hire You If You Can't Reverse a Binary Tree") about reversing a binary tree (with, as I remember it, the end goal being to ...
4
votes
1answer
37 views
Count words in string and tally up the repetitive words
I'm an elixir beginner. I'm doing the word count exercise of exercism website. The word count exercise returns a map with the word as the key and the number of instances as value. The exercise ...
4
votes
2answers
42 views
Unit testing Equals, hashcode and comparator - asserting contracts
After reading Joshua Blosh's Effective Java 2nd edition, I decided to implement equals, hashcode and comparable(where applicable) to every class I have been implementing.
I have written a generic ...
4
votes
1answer
94 views
Algorithms to find various kinds of paths in graphs
I think many here are familiar with the graph data structure. Not very long ago, I implemented as an exercise a supposedly simple Graph application that does some traversals. To note, the most complex ...
2
votes
1answer
45 views
Raindrops in Java
Problem Statement:
Write a program that converts a number to a string, the contents of
which depends on the number's prime factors.
If the number contains 3 as a prime factor, output ...
3
votes
3answers
54 views
Binary string to decimal conversion
Problem Statement:
Write a program that will convert a binary number, represented as a
string (e.g. '101010'), to its decimal equivalent using first
principles
Implement binary to decimal ...
5
votes
1answer
71 views
Let's revisit Roman numbers
Problem Statement:
Write a function to convert from normal numbers to Roman Numerals:
e.g.
1 => I
10 => X
7 => VII
Code:
...
2
votes
2answers
79 views
Let's play Scrabble
Problem:
Write a program that, given a word, computes the scrabble score for
that word.
Code:
...
1
vote
1answer
33 views
Private method to validate Excel header
I am new to unit testing and I am unsure how to design classes that use third party libraries, so that I can easily test them. The example I'll use is with EPPlus-...
4
votes
3answers
87 views
Solution for the BankOCR kata
Next Saturday I'd like to conduct a TDD demo in our local developer meetup. For this purpose I want to implement the first user story of the BankOCR kata from the Coding Dojo Wiki.
Here is the ...
8
votes
1answer
101 views
TDD - Kata - String Calculator
This is my first TDD Kata I've done and I'd appreciate it if someone could review it.
String Calculator
Create a simple String calculator with a method int Add(string
numbers)
...
3
votes
2answers
74 views
Unit test for a method that adds tweets to a database
I have a class which inserts a list of tweets to a database table and also inserts the tweet's key with the associated filter's key to a many-to-many table. I am testing the sole public method of this ...
1
vote
0answers
30 views
Testing a method which coordinates multiple objects
I have this class with one method, which uses three different objects to perform a task.
...
2
votes
3answers
99 views
Code Smell in Unit Testing Serialized Classes
I can feel that something is wrong with my code. Here's an excerpt where I think the code smell is...
...
4
votes
1answer
57 views
Unit Testing Input Class in Monogame
I'm new to unit testing, and to learn, I've decided to "contribute" to Monogame to help with their testing efforts. The issue at hand is to test the input device classes. I've started with the GamePad ...
2
votes
1answer
99 views
2
votes
1answer
74 views
Testing a shell command interpretor
I've written tests that use Bash for testing a custom shell. I think the tests work but I'm sure you know better because this is my first test I write this way.
...
4
votes
1answer
59 views
Alternate letters to UpperCase
As an exercise I repeated this Java question, but in Go: Convert string to mixed case
The objective is for every second letter to be converted to uppercase.
Go string processing is relatively new to ...
8
votes
3answers
530 views
A reference source for primes up to 64K (for unit tests)
In order to code the tests for my number theory library (a collection of routines that proved handy for coding challenges) I needed a reference source for primes up to 2^16.
I did not want to ...
4
votes
3answers
155 views
Count words in a string
Continuing my TDD from exercism.
Write a program that given a phrase can count the occurrences of each word in that phrase.
For example for the input ...
3
votes
1answer
37 views
Method injection into TestClass local namespace for automatic generation of Python unittest “test_xxx” methods
I am writing a series of unit tests in Python 3.5 unittest, which run the exact same test methods on different datasets. The purpose is to validate proper behavior ...
7
votes
3answers
203 views
Nucleotide Count
I am learning Java and hence practicing it from here. The solution seems pretty trivial to me but still I would like to have a honest review which would guide me to following ideas:
Am I maintaining ...
4
votes
0answers
79 views
Unit Testing Against Exceptions
I am writing a Swift library. I'm writing unit tests for that library.
I am afraid that some of the code that I am testing will possibly throw exceptions. In Swift, we can handle errors, but we can ...
3
votes
0answers
51 views
MSTest Data Driven Test Inline Data
Background:
Didn't what to have to reference bulky 3rd party lib for inline data driven tests and wanted to use standard MS testing framework.
Created helper ...
3
votes
1answer
115 views
Making the Levenshtein distance code cleaner
I was writing an implementation of Levenshtein distance in Python and I found my code really ugly.
Have you any idea how to make it more elegant?
...
6
votes
2answers
154 views
Expose a IDbSet<> object to overcome a limitation for LINQ's Select()
TL/DR: I have a Get() method which exposes a IDbSet<> object to overcome a limitation for LINQ's Select(). Is it considered leaky?
Long Post:
Hi everyone. Before posting this I have spent the ...
3
votes
2answers
78 views
First time writing test case
I have a list of input, a greedy method and a dynamic programming method. I wrote a unittest script to test my two methods with input list but I don't know if I'm writing it right:
...
0
votes
1answer
73 views
Web API with IoC and database integration tests [closed]
I've made integration tests for a major part of my application. I test my dependency injection is set up correctly, creating controllers with it's dependencies going all the way to the database (using ...
8
votes
2answers
93 views
Error-testing be with cucumber/capybaraweb
I'm working on writing tests for a rails application using cucumber and capybara. I have a scenario for a user editing a post, and making it invalid.
The scenario looks like this:
...
3
votes
3answers
157 views
Bowling scoring kata
I've been writing basic Python scripts for a while now to help process data or automate some task but I've decided I should start picking up unit testing and objective orientated programming (the vast ...
4
votes
1answer
66 views
Enumerating smart card terminals asynchronously in ViewModel constructor
I started a project the other day and started going down the path of using async and await as I have never used it before and it seems like a good match. The app that I'm making is a WPF solution ...
1
vote
1answer
23 views
Mini Test testing save on one and many trips
I know there is a balance to be struck between writing dry code and damp code but I have the feeling that this is a bit too repeative. Is there a terse yet self explainatory way to rewrite these ...
0
votes
1answer
56 views
A Java subclass of ArrayList that supports rotation in constant time - follow-up
(See the previous (and initial) iteration.)
Compared to the previous iteration, I have added more methods that maintain the invariant required for constant time rotations, such as bulk add/remove, ...
4
votes
0answers
84 views
Restructure of Express CORS middleware for unit test
How should one break this component down to better perform unit test on its behaviors?
Issues:
Authentication middleware component makes external request.
Must recognize preflight and final ...
1
vote
0answers
68 views
Connector for Odoo through xmlrpc (with testing code)
First time I write the tests before the actual code.
All fit in the same module.
...
7
votes
3answers
339 views
A Java subclass of ArrayList that supports rotation in constant time
(See the next iteration.)
I have subclassed java.util.ArrayList in order to be able to "rotate" it in constant time simply by moving a finger index. See what I ...
2
votes
1answer
45 views
XCTestCase#waitFalseExpectationUntilTimeout implementation
I am working on an iOS project and I'm in charge of testing most parts of it. As I write some tests, I often have the need to wait for an asynchronous method to finish, and then test that something ...
2
votes
0answers
86 views
Tiny calculator using dependency injection and inversion of control
I've started to learn very interesting concept of DI, IoC and related stuff.
I have decided to learn it using simple application, very tiny calculator (only basic functions: add, subtract, multiply ...
3
votes
1answer
73 views
Basic sorting in Python
Previously asked here.
I would like to get my code for implementation of simple sorting algorithms in idiomatic python code reviewed. I am looking for feedback on python idioms used, better ways of ...
4
votes
2answers
153 views
API call to a music provider
I have inherited a PHP base class for an API call to a music provider.
It is functional, however it makes me feel that there are some "magic" nature behind it that makes me un-easy (or maybe I'm not ...
1
vote
0answers
34 views
Unit tests for a Redshift wrapper class
I'm somewhat new to TDD and unit testing, but I've written a suite of unit tests to check my functionality. The basic classes automate simple load and unload operations from s3 and redshift, and ...
8
votes
1answer
93 views
“Curious Numbers” (HackerRank PE 34)
I was inspired by a certain recent question to try my hand at this challenge:
Project Euler #34: Digit factorials
\$19!\$ is a curious number, as \$1!+9!=1+362880=362881\$ is divisible
by ...
2
votes
0answers
42 views
Controlling the order of unittest.TestCases
Apparently everyone gets burned by their Python unittests not running in the order they want.
I am not in the business of telling people not to do perfectly reasonable things they want to do, so I ...
4
votes
1answer
107 views
Querying the Google ads API
I have a method which relies heavily on object supplied by third party APIs. Below is my working code, is there any scope of improvement?
...
2
votes
0answers
29 views
One class unit-tests
Its my first attempt to unit-test in Js. Not yet TDD.
What I can change?
EventsPersistancyService.js:
...
3
votes
2answers
78 views
Finding duplicates in given list of files
I implemented a simple tool to find duplicate files, by applying the following strategy:
Take a list of files and return the sets of duplicates (set of sets)
Implement a custom ...
7
votes
2answers
92 views
Unit testing F# code without using an existing test library (MSTest, xUnit, etc.)
I know I can probably use MSTest (I'm under Linux without an IDE so maybe not?) or another unit testing library, but for a small project I decided to write my own unit tests without resorting to a ...
4
votes
1answer
93 views
Testing an abstract class
I started writing a set of tests for my SageContextBase class, which needs to be abstract because the client code must derive ...
0
votes
1answer
121 views
CRAP index (56) in Web Scraper Engine
I am working on a Web Scraper for the first time using Test Driven Development, however I have caught myself into a huge CRAP (Change Risk Anti-Patterns) index (56) and I can not seem to find a ...