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

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 ...
-1
votes
0answers
11 views

Trying to understand Jasmine testing

Let's say in my application I have a script that triggers a click event on an html id. I want to then test that event in Jasmine. Below is the test I have in place for this scenario. I have a few ...
3
votes
1answer
98 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? ...
5
votes
1answer
74 views

Am I having a leaky abstraction? Unit of Work

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
1answer
56 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: ...
1
vote
0answers
14 views

Leaky DAL or anemic BLL? [migrated]

Particularly for the sake of unit testing, I'm trying to implement an application with a layered architecture. I'm coding in C# and using ASP.NET Web API for the service layer. I'm aiming at a 3-layer ...
0
votes
1answer
59 views

Web API with IoC and database integration tests [on hold]

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
83 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: ...
1
vote
1answer
67 views

Unit tests for an Express middleware function that does basic authentication

I have written an Express middleware function called authenticateRequest that looks at the Authorization header of an incoming ...
3
votes
3answers
136 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
55 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
21 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
52 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
74 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
33 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
328 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
31 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
75 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
69 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 ...
2
votes
0answers
42 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
18 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
77 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 ...
3
votes
0answers
37 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
105 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
27 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
54 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
63 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
87 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
118 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
52 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
27 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
65 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
77 views

Unit test if an event has been raised or not

Given the following event dispatcher code ...
8
votes
2answers
122 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
43 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
59 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
176 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
126 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
598 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
100 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
103 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
48 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 ...
4
votes
1answer
209 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
39 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
145 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
264 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
158 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
168 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 ...