Questions tagged [unit-testing]

Use this tag for code whose main focus is high-performance testing of the actual functional code.

91 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
23 votes
0 answers
397 views

Mucheck - a mutation analysis tool for Haskell programs

We have been working on a mutation analysis tool for Haskell tests called MuCheck. It accepts any Haskell source file, and a function name to mutate, applies a defined set of mutation operators on it, ...
Rahul Gopinath's user avatar
6 votes
0 answers
5k views

Cubic spline interpolation in Python from scratch

I implemented the cubic spline interpolation explained in https://en.wikipedia.org/wiki/Spline_interpolation as a Python class. Of course, such an interpolation should exist already in some Python ...
Ivan ZAR's user avatar
6 votes
0 answers
2k 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 ...
Nkosi's user avatar
  • 3,236
5 votes
0 answers
96 views

SmartUnit: Unit Testing with DI

I was thinking about how unit tests require you to manually instantiate all your dependencies, even though many of them are the same for every test or don't really matter (such as logging, where ...
Hosch250's user avatar
5 votes
0 answers
160 views

Using an extra mock simply to take advantage of the behaviour observation tooling

I'm writing integration for a project, but our framework doesn't provide any ability to inject dependencies, so I've written tests with a unit testing framework (GTest) and used a mock (GMock) in an ...
Matt's user avatar
  • 151
5 votes
0 answers
1k views

Mocking the file system within a test

I've been using this method to test file-system functions as an alternative to mock-fs due to its lack of symlink support. I'd love to hear what others think and ...
ThomasReggi's user avatar
4 votes
0 answers
100 views

Testing and coding conventions for testing C with SDL

I finished my first real C project and it was Conways Game of Life. The code is working fine and the game runs. Since this was my first project though I don't know any of the real code conventions for ...
Philipp's user avatar
  • 41
4 votes
0 answers
978 views

Jest - mocking a class function from an external node module

I am writing unit tests for a NestJS service, which imports and instantiates a class (OAuth2Client) from an external module (google-auth-library) and uses one of its functions (verifyIdToken). I am ...
hero121's user avatar
  • 41
4 votes
0 answers
115 views

Is there a better way to unit test a repository for a large aggregate root?

In our project we use domain-driven design and our customer aggregate root is large. The unit tests for the aggregate root itself are simple (~50 or so tests), but I am struggling with the repository ...
David Anderson's user avatar
4 votes
0 answers
100 views

Source Control and Unit Tests

Context This post will be related to the code request I asked for, some time ago. I would like to focus this time not strictly on the implementation of the ...
FlameHorizon's user avatar
4 votes
0 answers
1k views

Comparing almost equal Counters

I'm using (abusing) collections.Counter to hold non-negative floats. Something like Counter(a=4.5, b=3.4). The problem I faced ...
Dror Atariah's user avatar
4 votes
0 answers
352 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 ...
Michael's user avatar
  • 425
4 votes
0 answers
395 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 ...
nhgrif's user avatar
  • 25.3k
4 votes
0 answers
411 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 flight. ...
Brandon Clark's user avatar
4 votes
0 answers
1k 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 ...
tired_of_nitpickers's user avatar
4 votes
0 answers
60 views

Basic declarative style to rotate and crop an image array

I wrote a couple of basic Clojure functions (practicing a declarative style) and I was looking to get some feedback on them. You can see all the code here. Is there anything I could improve on to ...
mmbb's user avatar
  • 193
3 votes
0 answers
170 views

Fluent VBA: One Year Later

A little over a year ago, I asked for feedback on Code Review for a unit testing framework I created in VBA. Development of this project has been off and on for the past year. Sometimes I wouldn't ...
Brian Gonzalez's user avatar
3 votes
0 answers
122 views

Testing a javascript function that performs side effects

Application context I am working on a game I call "Apes and Snakes". So far the code only allows players to connect to a host using a room code and WebRTC. Players and the host send messages ...
Samuel Cole's user avatar
3 votes
0 answers
37 views

Command Line Utility for Starting Django Projects and Apps with Custom Files

What I'm Doing I'm writing a command line utility for starting Django projects and apps with custom files. The custom files build upon what Django offers, to make sure things like a custom auth user ...
mfonism's user avatar
  • 131
3 votes
0 answers
114 views

NavigationBar component with hooks. Can it be made more readable/maintainable?

I wrote a NavigationBar component in React, using hooks, react-bootstrap, react-i18next and css. Now the component works as I expect it, but the code seems ugly. (I'm new with hooks) Features: It's ...
Akos's user avatar
  • 51
3 votes
0 answers
316 views

UPDATED: Ambient time context to help unit testing

The following test demonstrates the functionality of Time class which is supposed to be used instead of DateTime.Now. You could ...
Dmitry Nogin's user avatar
  • 6,131
3 votes
0 answers
135 views

Sending push notifications to a user

I have a function whose responsibility is to send a push notification to a user. I call this function from a view in flask framework. I have read multiple articles around refactoring and good designs ...
anekix's user avatar
  • 161
3 votes
0 answers
331 views

JavaScript `localStorage` with `document.cookie` fallback for static web sites

The Code I've got things operating as desired so far and am hoping fresh eyes can point out any mistakes or bits that can be improved, a live demo is hosted and updated on GitHub Pages, Travis-CI ...
S0AndS0's user avatar
  • 976
3 votes
0 answers
50 views

Simple REST Base Web Server with Unit Tests

I am building out a simple web server in Go. My goal is to expand on this framework in a different application I am building. Here is my github repo https://github.com/jmacnc/gowebserver Is what I ...
jmacnc's user avatar
  • 31
3 votes
0 answers
40 views

GUI Button Element with Unit Tests follow-up

This is my second attempt with unit-tests. Like my previous attempt, I would prefer a focus on the unit-tests, however I am always happy to improve my code in any way reviewers can help. Once again ...
Summer's user avatar
  • 2,334
3 votes
0 answers
93 views

Paginator module in Elixir

I wrote this Paginator module that's part of a small application that displays Elixir Github repos in a table. I'm new to Elixir and looking for code improvements with as much as possible. Best ...
dan-klasson's user avatar
3 votes
0 answers
139 views

Unit testing a custom collection

To enable unit testing in the VBA IDE I'm using https://github.com/rubberduck-vba/Rubberduck. I've created a class and a custom collection class to work with structural members I need to filter. The ...
IvenBach's user avatar
  • 3,477
3 votes
0 answers
45 views

A simple test runner

When writing an answer for questions here or on Stack Overflow, it is a good idea to write some basic unit tests to make sure that the rewritten code performs as expected. To make this easier, I ...
Gerrit0's user avatar
  • 3,456
3 votes
0 answers
2k views

Testing a Django password reset procedure

I am writing tests for the password reset flow. It involves emails, links to reset the password etc so I made a really long test. It is testing quite a lot of things. If I break up the tests then the ...
user avatar
3 votes
0 answers
621 views

PHPUnit testing my custom helper Facade classes in Laravel 5.5

I have been reading up on TDD and it's something I genuinely want to learn and be good at. This is something I haven't been doing as a developer and I thought it's about time I get into it. These are ...
Latheesan's user avatar
  • 283
3 votes
0 answers
302 views

linspace c++ and unit tests in catch BDD

I have implemented matlab's linspace function ...
Gilad's user avatar
  • 5,321
3 votes
0 answers
41 views

Test Driven Development in JS and Sinon Stub

I am going through some TDD and BDD tutorials which guide one through implementing a simple beverage-ordering system. While I think I understand the material, I am still wondering about some ...
MadPhysicist's user avatar
3 votes
0 answers
49 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 ...
Cobertos's user avatar
  • 375
3 votes
0 answers
1k 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 ...
Sebastian Kramer's user avatar
3 votes
0 answers
1k 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 &...
Matthew Tipton's user avatar
3 votes
0 answers
872 views

Laravel Testing: Is this testing too much of the inner workings?

So I'm using laravel for a project and have a InvoiceRepository and a InvoiceRepositoryTest and I have written the test first ...
toonevdb's user avatar
  • 131
3 votes
0 answers
3k views

Unit testing event triggering

I am writing a unit test for a Dispatcher that will route a HTTP request to a specific Controller and invoke a specific method on that Controller. It will also trigger various events at different ...
Charles Sprayberry's user avatar
3 votes
0 answers
922 views

Testing Scala code which depends on objects

I am writing a small oauth2 library for Play! 2.1 scala. As I am still learning I got stuck trying to TDD and ended up writing the code first, then refactoring for testability. By testability I mean ...
Jean's user avatar
  • 528
2 votes
0 answers
65 views

Get ffmpeg command to encode video in x265 codec and downscale to `max_height` resolution

I'm translating the python program video-diet as I am learning rust. The program is to recursively compress video files in a directory, but here I'm just preparing ...
user avatar
2 votes
0 answers
39 views

SpecFlow/gherkin code for creating customers

I am new to BDD/Specflow and was wondering if I could get some feedback on my definitions Here is what I have for a simple customer creation feature/command: ...
Matster2's user avatar
2 votes
0 answers
89 views

A terminal based atom feed reader written in golang

I'm a beginner trying to get a better understanding of golang so I decided to write an atom feeder that runs from the terminal. I am using the gofeed library to parse the atom feeds and the tview ...
barryodev's user avatar
  • 121
2 votes
0 answers
38 views

Interactive, real-time bikeshare web application with Bokeh

As a side project, I'm working on a Bokeh web application to display public bikeshare data on a map. The data is updated every 2 minutes using a periodic callback. Below is the full implementation. I'...
keves1's user avatar
  • 21
2 votes
0 answers
53 views

Rainfall challenge: procedural implementation

This evening I have seen the text of the Rainfall Challenge posted seven years ago by Hunter McMillen. I did not look at his solution (besides, I have no clue about perl), but I was intrigued by the ...
Luca Argenti's user avatar
2 votes
0 answers
46 views

Unit Test template function with terminal input

I wrote some template function, which helps me with reading input from terminal, doing error handling, validating input. The full code with template specialisation for strings looks like this: ...
Leon0402's user avatar
2 votes
0 answers
39 views

Google Mailer app inside Django using OAuth 2.0

I have built this Django Package which is an alternative for sending mail to users using Gmail API. Everything is working fine. But the verify(self, request) method inside ...
NikzJon's user avatar
  • 121
2 votes
0 answers
72 views

Building a GTD Productivity App Designed through Test Driven Development (TDD)

First, thanks so much for looking at my code. Over the past decade, I have tried every task management apps imaginable. I finally realized that the only way I would ever find my perfect productivity ...
Darrion Burgess's user avatar
2 votes
0 answers
71 views

Express compatible JSON Web Token authentication middleware

I am writing an Express.js middleware function in a TypeScript NodeJS project that uses a function from a third-party module to perform a small workload. When writing unit tests, I want to mock this ...
Patrick's user avatar
  • 263
2 votes
0 answers
45 views

Finding, substituting and executing values in dictionaries

I wrote this code for finding, substituting and executing values in dictionary, much like $() bash operator works. I used nested functions for this, forming ...
nonForgivingJesus's user avatar
2 votes
0 answers
552 views

Tests for redis wrapper

I've written a wrapper package for redis. The idea is to be able to provide better error reporting with the package, as well as integrating stats and logging at a later stage. For now it's just better ...
SynackSA's user avatar
  • 121
2 votes
0 answers
48 views

Laravel testing for compatibility between old and new password-hashing schemes

I currently have an event listener tied to Laravel's Attempting class. The listener is designed to rehash an old password to something newer. The current DB stores ...
ThePoet444's user avatar