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)

4
votes
1answer
52 views

Jasmine unit tests for a function to set attributes on an HTML element

I'm new to unit testing so maybe I have this all wrong, but it seems kind of useless. I want to reduce bugs and integrate some tests with a build process however I'm not seeing the benefit at the ...
0
votes
0answers
10 views

Best DI (Dependency Injection) library patterns [closed]

Many JS developers will be aware of the DI patterns used by Angular 1.0 and RequireJS, as a reminder, they look something like this: ...
1
vote
0answers
47 views

Extract value from first row of last series of a grouped variable

I've written code to calculate travel times for a small tagged population of fish. My dataframe d of each fish's "path" looks like this: ...
4
votes
0answers
25 views

Test cases for Ansible lambda module for deployment of AWS Lambdas

I have written a set of test cases which cover the ansible lambda module. The entire source is available on GitHub, forked from ansible/ansible The original file is visible on github as is the ...
2
votes
2answers
97 views

Windows forms application for a Cubscout Pinewood Derby

I have a pretty simple C# windows forms application working here. It is used for creating and running a Cubscout Pinewood Derby. You can create dens, assign them cars, generate a race schedule and ...
0
votes
0answers
36 views

Using interface to decouple from database connection

I have an issue regarding unit testing for getting the response that created using http.HandleFunc(). This is about my approach to solve this problem. I create ...
3
votes
1answer
49 views

JUnit assertion for concurrency test

I'm learning Java concurrency by a TDD approach. Therefore I wrote a basic test case in JUnit to test the behaviour / expected results of 2 threads. I'm looking for feedback for this code. In ...
5
votes
2answers
43 views

Test Driven Development with Django

I'm learning TDD with Django and currently I'm testing my CreateView class. I feel like I'm not using best practices but am not sure on how to improve my code. ...
2
votes
1answer
67 views

Suppress console output from React in Jest testing output but not in browser output

I have a React app that I am testing with the built-in jest testing tools. In the process of debugging, I sometimes send data to the console (e.g. console.log, <...
1
vote
2answers
67 views

Good Unit Tests when ReSharper bugs for null checks

I have the latest version of ReSharper installed and I am trying to write a Unit Test for my MVC controller. I need the Unit Test to: Ensure the ViewModel passed to the View is of the correct type. ...
7
votes
1answer
76 views

Generate iCalendar .ics files with events for astrological aspects

I'm relatively new to Python, coming from a deep C++ background. I'm mostly looking for feedback on how to make my code more idiomatic/pythonic, but I would welcome and appreciate any and all other ...
6
votes
1answer
126 views

Support static typing / analysis with dependency injection

I am working on creating a test library, and I found DI to be pretty convenient, maybe even to create more functional coding patterns. Normally we can have an awkward before-hook setup in Node.js ...
2
votes
0answers
40 views

Struggling to unit test Angular, was this module the best approach?

As a development team we've recently started to transition from MVC to Angular. None of us have had prior experience with it so a lot of creating the new client was very much trial and error. I've ...
2
votes
1answer
46 views

Compression unit test data “easy case”

In another post I created a piece of data, which make compressor annoyed. Create 'worst case test' data for compression test Now I am trying to make it happy. I generate another data set, ...
0
votes
0answers
32 views

Java class 'SymmetricEncryption': Caesar Cipher, ROT13, Vigenere

I had to do the following exercise: Write a class 'Symmetric Encryption' which has methods for the following encryption techniques: Caesar Cipher ROT13 (Simplified) Vigenere Cipher The precise ...
8
votes
2answers
110 views

Create 'worst case test' data for compression test

I am going to prepare some test data for a compression test. One of the them is the 'worst case test', which should make the compressor work worst. Use random number to generate such a file is an ...
4
votes
1answer
73 views

Assembly Line Scheduling challenge, solved using TDD

I am new to Test Driven Development and currently practicing it with some problem statement. Following is an Assembly Line Problem statement I solved using TDD approach in java. Please provide me some ...
3
votes
1answer
50 views

Small unit testing framework

Here is a single-header small unit testing framework I wrote, that makes use of mostly preprocessor macros. I made it for knowing how unit testing works and, also, try to depend less of third-party ...
6
votes
1answer
78 views

Mocking UserDefaults in Swift

In my application, I am using UserDefaults to save some data. I also started writing tests for testing my application code. At one place I stuck where I wanted to ...
1
vote
0answers
22 views

XMPP XML Parsing and Tests in Swift

I am implementing chat app using XMPP. Here is my XML Parser function which tells me whether given XML is file transfer offer or not: XMPPIQ+FileTransfer Extension-> ...
3
votes
1answer
90 views

Calculating the angle between the clock's hour and minute hands with unit testing

I am learning PHP OOP and unit testing so I made a code using OOP and TDD approach where it calculates the degree of and angle betwee the clock's hour and minute hands. I would like to know: Is the ...
4
votes
0answers
40 views

Unit tests for React component to submit an input form with validation

I'm very new to front-end/unit testing and have been having a difficult time understanding the point altogether, but I managed to push my way through testing literally everything I could possibly ...
3
votes
1answer
67 views

Proxy test class approach to allow covering legacy code with unit tests

There is huge legacy class MyService in which several new business cases need to be implemented. Unfortunately we are not allowed to touch existing legacy code ...
5
votes
2answers
89 views

C++ Query String Parser

This query string parser is intended to parse the parameters and values of a parser query string. I'm particularly concerned about my use of std::move(...). I ...
1
vote
0answers
33 views

Unit testing for sending messages

I'm new to testing in Meteor, so I'm worried if my implementation is not going in the right directions. I've written a unit test for my send method which sends a ...
4
votes
1answer
60 views

A JavaScript implementation of the Python's range() function

Recently I implemented the Python's range() function in JavaScript. The function has three parameters: start, ...
8
votes
2answers
130 views

Yet Another Todo API

I've been on an adventure trying to learn NodeJs and put together a stack that I'd be happy to put into production if one day my team said to me "Let's build it in Node!". What we have here is your ...
1
vote
0answers
28 views

Unit test for my image resizer class

I made a class that will be used to get an image properties like width, height, and MIME type. ...
1
vote
2answers
69 views

PHPUnit test for a PaymentMethodRuleManager

The following code snippet is about adding rules that filters Payment Methods listing to customer, for email we provide 4 different types of payment methods, but we do show them depending on some ...
2
votes
2answers
180 views

Table Driven Test in Java using Junit4

I was creating some solving algorithm and write test for it. this is the tests : ...
9
votes
1answer
135 views

Command Tokenizer

I've written some code to tokenize a command string into its tokens. A token is either: A block of any non-whitespace characters A block of characters, which may include whitespace, wrapped in ...
3
votes
1answer
123 views

Testing an Address Book

I have completed the following coding exercise. However, I got poor result for testing. I need some help to find out what is missed, incorrect, or incomplete in the testing section. I would appreciate ...
0
votes
0answers
32 views

Single integration test written using reflection to test routing

We have two .NET solutions: WebAPI solution that contains all business logic and repositories, MVC project that represents a presentation layer of the application. In WebAPI solution we also have a ...
3
votes
1answer
60 views

Extracting complete lines from a data stream

When reading from the Console, it's very easy to get a complete line, you simply call Console.Readline. When reading from a ...
8
votes
1answer
100 views

Unit-testing friendly singleton

In my project we have a few singletons, which tends to be problematic in unit tests. So I wanted to find solution for the problem. Here is what I came with so far: smart_singleton.h ...
2
votes
2answers
53 views

Fraction class with documentation

I have never worked with Ruby before, and thought I'd start working on learning it. For my first little implementation, I have created a simple fraction class. It would be nice if someone would check ...
4
votes
2answers
76 views

Java REST-assured acceptance tests

I've have experience in unit testing but I'm fairly new to acceptance testing and REST-assured. I would like to get some feedback on my style. This is not a complete list of all my test but a few that ...
1
vote
2answers
61 views

Title capitalization exercise from The Odin Project

I just finished the book title class exercise for The Odin Project and I would appreciate some honest feedback for my code. The code is intended to be "test-driven learning", and therefore emulates ...
1
vote
2answers
220 views

Login page with Selenium webdriver

I am automating a login page. I am using the page object design pattern Selenium with Java. What should I improve on in my code? ...
2
votes
1answer
49 views

Unit testing for a blog post model on Google App Engine

It is my second day into software testing and I am currently testing my database, handlers, and functions. I am wondering if I am taking the right approach as this is the first time testing my web app....
4
votes
3answers
531 views

Testing a Random number generator

Firstly, would appreciate some code-review feedback, from a TDD and design perspective. Secondly, what are your thoughts on implementing test case: ...
4
votes
1answer
100 views

Testing a Pivotal API request client using lots of mocking

I have a class that is all about doing HTTP requests, and logging (in file system & database). It's only using 3 dependencies to do these things, so I'm fine with the code so far. Here it is for ...
2
votes
1answer
150 views

Analyze Shakespeare's Macbeth parsing XML from web using Nokogiri

This is a simple Ruby program to analyze the number of lines characters speak in Shakespeare's Macbeth using Nokogiri and open-uri to parse a given url containing xml. I wrote this as practice getting ...
5
votes
5answers
177 views

Taxi Meter App Business Logic Using TDD

The following problem has been written using TDD. Please review the following: Unit tests OOP Design Principles (SOLID) Cleanliness and naming Anything that could make the program better. Problem ...
0
votes
0answers
28 views

Testing the Dutch national flag task - revision 2

Revision 1 Suppose I implement the Dutch national flag problem and want to test if my implementation is correct. I write the following method verifyDutch which ...
0
votes
0answers
55 views

Testing the Dutch national flag task

I recently coded the Dutch national flag problem in Java and wrote some tests. The array in zero-indexed. Please take a look at how I verify that elements of the output array are in the right order. ...
3
votes
0answers
30 views

Unit tests feel too much like an integration test. Multiple code paths

I'm having some trouble isolating the parts of my code enough for unit testing to make them simple and easy to maintain. The code I'm writing feels like an integration test because most of what I'm ...
3
votes
1answer
83 views

Retrieving a thumbnail photo for an ActiveDirectory account

I have the following method and I would like to understand how it could be reorganized to be more unit-testable. I think the section about binding to Active Directory could go to its own method, ...
2
votes
1answer
267 views

Computing the profit or loss from a list of trades

I am coming from C# and I am learning how to use Python more seriously. So I decided to try a little side project to help me see how much I earn (or lose) from my trades on the stock market. I would ...
4
votes
3answers
126 views

Detecting interesting car mileages

I've had a go at the following challenge (from codewars): Interesting car mileages are 3-or-more digit numbers that meet one or more of the following criteria: Any digit followed by all ...