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)

3
votes
1answer
54 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
77 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 ...
1
vote
2answers
44 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
55 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
28 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
1answer
57 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
42 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
479 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
86 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
131 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
164 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
24 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
51 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
50 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
188 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
124 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 ...
1
vote
1answer
161 views

Testing a ViewModel in Android - MVVM with DataBinding

I am using MVVM pattern with databinding. I have written tests. But I want them reviewed. The test is related to JUnit test on the ViewModel. FeedViewModelTest....
2
votes
1answer
64 views

Testing controller class using mockito mvc

I'm beginner java programmer and would like to ask you to take a look at my code. I wrote small rest service among with tests. Now I have to questions to ask. The test methods: ...
3
votes
1answer
52 views

ApplicationSettings Class for disabling/restoring Application State

This previous iteration of this question can be found here A utility class to handle the state of the Application object. Storing the application's initial state (...
1
vote
1answer
36 views

ApplicationSettings Class (Store, Restore, Disable, Reset)

Update: This question has a follow-up here A utility class to handle the ubiquitous "turn off ScreenUpdating, Calculation, Events etc" for executing VBA code, and ...
7
votes
2answers
83 views

Python unit testing for a Stack data structure

I am completely new to unit testing. I read this chapter in Dive Into Python 3, and decided to give it a try on a basic data structure: a stack. Here is the stack code (taken from "Problem Solving ...
0
votes
1answer
41 views

How can I extract these similar codes into only one method? [closed]

I have implemented three ways of Singleton idiom in Java, and now I want to write some test code to see there performance. Here is my code: ...
2
votes
2answers
89 views

'Zero out' a matrix using Python

Below is my code for an attempted solution to cracking the coding interview exercise 1.8 written in python 3.5. The problem statement is: Write an algorithm such that if an element in an MxN ...
2
votes
0answers
53 views

One-based array in JavaScript

One day I stumbled upon a question on Stack Overflow: How do I create an array in javascript whose index starts from 1. The top answer says that it's impossible. However, that answer was posted ...
12
votes
4answers
206 views

Lines, intersections and terrible unit tests

I needed Line and LineF for the next stage of a project I'm working on, so I developed them. I also needed to determine if two ...
2
votes
1answer
73 views

Unit testing a prism event

I am currently working on a C# WPF project following the MVVM design pattern. I am using Autofac and Prism as core frameworks in the design. For unit testing I am using Xunit and Moq. I am also using ...
2
votes
2answers
73 views

EntityFramework UnitTest

I just want to know what can be done to make this code smaller in a nice and easy way. Tests ...
2
votes
1answer
31 views

Using mocking to test that a Django view renders as expected

I have a Django view that ends with this... return render(request, 'define/see_all.html', context) I have mocked the render function and ...
3
votes
1answer
64 views

Simple geometry problems involving rectangles and circles in Python 3

I'm working with some simple geometry problems featuring rectangles and circles. My code is as follows: ...
8
votes
3answers
99 views

Representing and handling Data Sizes

In a very specific application I have, I needed the ability to easily convert between different data sizes. I.e. when I give an input of 1,048,576KiB, I needed it to say 1GiB, etc. So, I built a <...
1
vote
0answers
36 views

Node Automation Project - Unit Testing, Possible Issues, Standards

Info I usually do automation and integration testing with Selenium but have heard good things about some of the Node headless frameworks. So I put this project together to get some experience with ...
2
votes
1answer
87 views
1
vote
0answers
40 views

More testable file upload code

I am writing a backend with Node JS. It is my first Node JS application so I haven't learnt all the principles Node involves. I am writing the code for a media upload mechanism (to handle profile ...
7
votes
2answers
136 views

Utility method to view submatrices

I implemented an utility method that is able to view an Array[n, m] in another smaller dimension [k, l], where ...
4
votes
1answer
98 views

WAKE UP! CodingBat alarm clock

I'm brand new at Python, but I've been working in general at granulating my functions and being as self-readable as possible without suffering readability. This CodingBat question is a little ...
1
vote
1answer
76 views

Unit test Web API controller that uses a static helper class which uses app config setting

I have a situation where I have a static class that reads my application configuration file for some configuration value. When unit testing Web API controllers that make use of this static class I am ...
3
votes
2answers
140 views

RPG character, levelUp system and stat checking for object usage

So I am working on a small RPG in Unity. Right now I am writing some business classes, POCOs, that have no link to Unity except being in the required C# flavor and using Debug.Log and stuff. I have ...
6
votes
1answer
79 views

Unit test for allowable checkers moves

Is pattern matching within a unit test a code smell? Do I really need to throw an exception just for my test to fail if the function under test receives invalid arguments (i.e. not Succeeded case ...
1
vote
1answer
48 views

Functional tests for a web app repeating the same code

My problem/concern is that I am trying to remove duplicate code from my functional tests without breaking the Page Object Pattern that I am following. If you look at the code below, you will notice ...
6
votes
2answers
86 views

Testing Out Testing

I've been learning about unit testing with pytest recently, trying to figure out what is and isn't a valuable thing to test. I'm very new to it, so I thought a review would be a good way to learn ...
6
votes
1answer
356 views

Multiple permission checks in web app automated tests

I am writing automated tests for a web app and at one point I need to make sure that a user can only engage in activities allowed by a set permission. I have written all the standalone methods that ...
1
vote
1answer
49 views

Idiomatic F# unit test using xunit and unquote

I'm writing some unit tests for testing C# code but I'm using F# and Unquote for the first time for the unit tests and would like some input as to how I might make the tests more 'f-sharpier' to take ...
2
votes
0answers
44 views

Roman number converter in Kotlin

I'm learning kotlin and java. As a code-kata I wrote the roman to decimal converter. I'd be very grateful for code review. I was trying to keep things simple and funcional. I'd especially appreciate ...
5
votes
1answer
62 views

Testing file IO errors in python

Below is a simple class with two methods: the first calls open() to read in a file. The second calls the first method and does error handling. There is also a ...
1
vote
2answers
73 views

Webdriver-based test that uses configuration parameters from a database [closed]

I am writing automated functional tests for my application. To interact with the application, I use the SQL database to retrieve data and validate data. One of the challenges that I'm facing is that ...
1
vote
2answers
46 views

Function for getting strings consisting of random characters

I've made this function for to be used while testing. ...
5
votes
0answers
49 views

Mocking config data in JavaScript unit tests

I'd really like someone to sanity check my approach for unit testing the summarise() function and mocking its dependencies. Background Each option has a set of ...
4
votes
1answer
41 views

Takes function and throws exception if passed function doesn't throw an exception

The code below is part of a toy test assertion library I've written. I'm looking for feedback specifically on lines 4 - 9. I'd like to extract them from the ...
3
votes
4answers
83 views

Unit testing for concatenating two int arrays

Using Java 1.8, I created the following implementation to concat two int arrays: ...