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 (1)

1
vote
0answers
9 views

Restructure of Node CORS middleware for unit test

How should one break this component down to better perform unit test? Issues: Authentication middleware component makes external request. Must recognize preflight and final flight. (Exceptions) ...
1
vote
0answers
12 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. ...
6
votes
3answers
249 views

A Java subclass of ArrayList that supports rotation in constant time

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 have: RotableList.java ...
1
vote
0answers
9 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 ...
1
vote
0answers
56 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
52 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 ...
1
vote
0answers
36 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
6 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 ...
7
votes
1answer
63 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
32 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
104 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? ...
1
vote
0answers
26 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
53 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
54 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
85 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
116 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 ...
2
votes
1answer
49 views

Sampling with weighted probabilities

In an exam question I need to output some numbers self.random_nums with a certain probability self.probabilities: I have ...
2
votes
1answer
26 views

Testing a socket-based application

Summary: How can I best write tests that override socket-based communication for a library, capturing what is sent over the socket, and simulating responses based on what is sent? Details I'm adding ...
5
votes
2answers
60 views

Recursive binary search implementation in Python

I have this (recursive) binary search implementation in Python, and I want you to criticize every aspect of it. It is a naive implementation, (drilling the basics and stuff), but, I want you to ...
0
votes
0answers
20 views

Validate if time is valid including tests

So, I'm working on a method to validate if given time(s) are valid. In most cases, the input comes from the user. I'm not exactly sure on a few points: Readability Integrity Performance I'm also ...
5
votes
1answer
73 views

Unit test if an event has been raised or not

Given the following event dispatcher code ...
8
votes
2answers
121 views

Next number with the same sum of digits

I recently came across a email bot that would give you random problems to solve. Here is the problem. Please write a function in python which receives a natural decimal N-digit number (1 to 15 ...
4
votes
1answer
41 views

String concatenation comparisons

For some time, JavaScript string concatenation could be optimised by join()ing an array of strings, instead of +ing them ...
4
votes
1answer
56 views

Simple Ruby program to model a prepaid transit card system

I have written a simple Ruby program to model a transit card system which aims to address the following user stories. I wanted to see whether I could get any feedback on it. My main interest is ...
6
votes
4answers
134 views

Unit Testing the Duck

I recently reinstated the unit tests in Rubberduck. Previously, our parser was a synchronous parser, with everything running in sequence, and we could just request a parse result. Now, however, it ...
6
votes
1answer
138 views

Creates a menu and sidebar in Google Spreadsheets

In an effort to make my code more testable, I'm trying to make use of constructors and prototypes. Here is a working Google Apps Script (GAS) for creating a new submenu under the Addon main menu in a ...
8
votes
2answers
117 views

Number to Roman numerals

I've been working on numerals conversion lately. Now the JavaScript course I'm following asked me to do something similar for Roman numerals. To keep things fresh and given the amount of test-cases ...
7
votes
2answers
596 views

Simple DateTime abstraction

Some of my tests require that I need to test the date time results (like time stamps etc.). In order to be able to test the date time string I created a simple ...
2
votes
2answers
99 views

Check if a word is before another

Let's consider a method like this: public bool IsWordABeforeWordB(string Text, string WordA, string WordB) { ... } By Word ...
2
votes
0answers
100 views

ASP.NET MVC with automatic testing (follow up)

This is a follow-up of this question regarding MVC application architecture fit for automatic testing. I have rewritten the DI code based on the answer provided there and also created some tests to ...
4
votes
1answer
47 views

This function for populating the attributes of a class, using a DB model and REST API

Recently, I've been trying to transform my code to be more OO and adhere to SOLID principles. I also have been trying to get into the habit of making my code more testable and have been trying to ...
3
votes
1answer
122 views

Unit testing with dependency injection and MOQ

I'm just learning how dependency injection and mocking work, but I'd like some feedback on how I'm setting up a couple of tests. I can get them to pass, but I'm not sure this is all I need. This is ...
3
votes
0answers
35 views

CIDR Notation parser

I created the following code to better understand CIDR notation. Also to learn some of the Stream features in Java8. I posted my unit tests too. I'm interested in ways it might be improved ...
1
vote
1answer
129 views

ASP.NET MVC application architecture fit for unit testing with mocking

I am trying to learn how to professionally work with unit testing, so I have refactored a medium sized project of mine (a sort of article aggregator that also does some NLP processing) and tried to ...
14
votes
2answers
250 views

All your bases are belong to Dijkstra

CATS, willing to get a hold of all the bases, asked Dijkstra to give him a hand designing the most powerful algorithm to reach all bases with the least distance travelled. I tried to implement ...
5
votes
1answer
149 views

Geocoding hook for a TYPO3 extension

I'm currently developing a TYPO3 Extension in PHP and developed a Hook. TYPO3 has the concept of Hooks where you can execute your own code as specific points. As defined in our definition of done, we ...
5
votes
4answers
142 views

Writing to a newly created file, with support for unit testing

When now increasingly making code unit testable, I notice that code gets bloated, only to get dependencies out. A simple file operation, like saving a file, and, if a file with the name already ...
3
votes
1answer
83 views

Unit Testing Express Middleware That Verifies Auth Tokens

I am writing an Express middleware component that'll run on Node 4, which has limited ES2015 support. The fundamental purpose of this component is to verify JSON web tokens, using the jsonwebtoken ...
2
votes
1answer
28 views

Converting fraction notation in strings to a Rational data type

I've been messing around with a RationalInt type, using a simple int-based structure for the time being. I've created code to ...
9
votes
1answer
106 views

Tokenize s-expressions in Rust

I'm writing an s-expression tokenizer in Rust. I have the following code written, but it is not idiomatic Rust - it is quite ugly. TokenizerI is simply an ...
11
votes
4answers
738 views

Using reflection in a test to check if a private variable is really null after a function, is this okay?

I am using reflection to check if a private variable is set to null after the logout function. This is needed because the getUser function will always attempt to set and return an user if no user is ...
3
votes
1answer
51 views

Test cases for an elevator simulator

I'm trying to test an elevator simulator program that runs in the console and requires user interaction. At the moment, my tests look like this: ...
0
votes
1answer
91 views

Angular directive test

I'm learning how to write tests in Angular (these are my first tests in general). There are a lot of tutorials out there but each one of them has a different approach. I'm a bit confused if I'm doing ...
2
votes
2answers
62 views

Sales Tax problem (new version)

I was told that this version is too simple, that need something more complex. I added Entity Framework. Here my code: ...
1
vote
0answers
72 views

Integration tests for a repository with the help of AutoFixture

I find it hard to do integration tests for a repository and very time consuming. Things I think about when creating integration tests for a repository: Should I skip them? Should I create an in ...
14
votes
2answers
132 views

Builder pattern for users in document database

I'm attempting to make a builder pattern that makes sense and is practical for storing user data in a flexible way in a document database. The DB I chose is MongoDB, and I'm using its Java API ...
8
votes
4answers
349 views

Implementing common fraction using TDD

Recently, during the interview, I was asked to implement basic arithmetic operations with common fractions using TDD. The task is fairly simple, but I was nervous so I did not do too well. :) Later on ...
1
vote
0answers
128 views

REST service API using Python Bottle

I am working on a sample REST service to study testing related aspects using the Python Bottle framework. I read a lot about REST but I do not have a lot of practical experience designing RESTful APIs ...
6
votes
2answers
128 views

String Calculator Kata in Scala

This is my solution of string calulator kata in scala(i'm new of tdd). I'd like a general review of this. String Calculator Create a simple String calculator with a method int Add(string ...
1
vote
1answer
618 views

Entity Framework 7 In Memory Database - Unit Testing using xUnit

I'm using EF7 with In-Memory database and xUnit for repository testing. I'd like to know if it's a good practice initializing the database in this manner for reuse it in every test method, ...