Questions tagged [unit-testing]

Unit testing is a method by which individual units of source code are tested to determine if they are fit for use.

Filter by
Sorted by
Tagged with
-1 votes
0 answers
29 views

Domain modelling of data intensive applications (crawler) [closed]

I am refactoring various microservices into a single monolith, this application is first and foremost a crawler, but which then will process the crawled data in various ways and will extract features, ...
user avatar
0 votes
0 answers
10 views

Testing out whether controller response body contains correct data in Rspec Controller specs

Running Rails 7.0.3, Ruby 3.1.2 and rspec-rails 6.0.0rc1 I'm writing out some specs to test for the inclusion of certain data getting sent by my controllers. A ...
user avatar
  • 185
2 votes
1 answer
56 views

String / Char Vector Concatenation Performance Comparison in Matlab

Considering the suggestion of using modern string arrays instead of char vectors proposed by Cris Luengo, I am trying to make a code snippet for performance comparison of these two cases. The ...
user avatar
  • 3,546
1 vote
0 answers
36 views

Reusable and testable JavaScript code for URL fragment-based tab navigation logic

Foreword As a personal project, I've been creating a SPA blog (available here), which features 4 tabs (Thoughts, Projects, Readings, and CV), each accessible via one of four radio buttons, and several ...
user avatar
  • 507
1 vote
0 answers
36 views

UPDATE on Newspaper Bill Calculator CLI with Python (3 of 3, Database)

Code is posted after explanation. Due to the size of the project, this is being posted in three separate posts. This also ensures each post is more focused. Post 1 of 3, Core: UPDATE 1 on Newspaper ...
user avatar
1 vote
2 answers
68 views

UPDATE on Newspaper Bill Calculator CLI with Python (1 of 3, Core)

Code is posted after explanation. Due to the size of the project, this is being posted in three separate posts. This also ensures each post is more focused. Post 2 of 3, CLI: UPDATE 1 on Newspaper ...
user avatar
2 votes
0 answers
19 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
1 vote
1 answer
38 views

Unit tests for PNGme steganography exercise in Rust

I want to become proficient in Rust and I've followed the PNGme exercise. I've completed it up until Chapter 4 included, where I've written a lot of tests myself for verifying that the command line ...
user avatar
  • 111
0 votes
0 answers
49 views

Table driven tests in Python using pytest

I'd like to have a standard test template to copy from when solving coding puzzles. Typically, I would need to write multiple test functions to check if my function is working as expected. However, it'...
user avatar
2 votes
1 answer
72 views

Newspaper Bill Calculator CLI with Python (1 of 3, Core)

Code is posted after explanation. Due to the size of the project, this is being posted in three separate posts. This also ensures each post is more focused. Post 2 of 3, CLI: Newspaper Bill ...
user avatar
0 votes
0 answers
57 views

Skeleton unit test for leetcode coding problems

I tried to initiate myself with unit testing the simplest way I can. What do you think of this way to begin with? Is it a clean way to proceed? Are there any major caveats to avoid? NB: Since I want ...
user avatar
  • 273
3 votes
3 answers
227 views

A refactored payment service, handling several payment schemes

I was asked to refactor a class, to make it adhere to SOLID principles, with testability and readability. I thought I had done a decent job, only my feedback was: a) Unnecessary introduction of ...
user avatar
  • 140
1 vote
1 answer
111 views

Unit tests for a 2D Vector class

I'm writing a vector class for 2D geometry applications, and below is a rough draft for a unit test using Cpputest. I'm familiar with unit tests, but this is the first I've done for a purely ...
user avatar
  • 333
2 votes
0 answers
21 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: ...
user avatar
2 votes
1 answer
112 views

Basic Ticket booking code with Unit tests

I am going to run a session for a few other developers who are new to Junit, mocking, etc. I have designed a very simple application with classes and tests to demonstrate how to do unit testing. ...
user avatar
0 votes
0 answers
22 views

Testsuite for implementation of the command pattern

I've attempted to introduce the command pattern for my use-cases. I would like some feedback on my Test suite. I've tried to delegate as much responsibility to other classes/functions so the primary ...
user avatar
  • 163
0 votes
1 answer
57 views

First time writing tests (Service Layer)

Service class: ...
user avatar
  • 51
0 votes
1 answer
41 views

Six different, concise (and hopefuly readable), sorting algorithms using ES6+ idioms, with some basic unit testing

I'm practicing js, unit testing, and algorithms, so implementing some of the common sorting algorithms and doing some basic unit testing on them seemed like a good exercise. I'm also trying to use ...
user avatar
  • 729
1 vote
0 answers
37 views

Unit tests coverage of functools extension library

A few days ago I requested a review of my functools extension library. Since I did not have any unit tests for it, I started writing some for the revised version of this library. I'd like some ...
user avatar
2 votes
1 answer
113 views

Operator overloading in Image class implementation in C++

This is a follow-up question for Dictionary based non-local mean implementation in C++. There are some issues about operators (operator+ and ...
user avatar
  • 3,546
0 votes
1 answer
36 views

Sanitize object to only include specific properties

Object Property Sanitization I'm learning to code servers using JavaScript, Node, and Express. While writing controllers that create new entries in the database, the need to sanitize the user input ...
user avatar
  • 729
1 vote
1 answer
24 views

Optimize Tests in Rails6 - Minitest - Factory

I finally got this working but I am concerned I am being 'too' specific in my tests, and also that I am repeating myself a significant amount. I could also combine all of the failures into a single ...
user avatar
0 votes
2 answers
101 views

Binary search with self-test

Here is an implementation of binary search. Please give feedback on any part but a few specific areas I was wondering about. Is size_t used appropriately or should ...
user avatar
0 votes
1 answer
49 views

RSpec: Compound Expectations

It's an exercise from a RSpec-course, which I'm currently doing. Task: Create a compound expectation, which asserts the string sportscar starts with the substring "sports" and ends with the ...
user avatar
  • 3,758
3 votes
1 answer
60 views

Functional tests of downloadpdf, a python CLI app

Shared below is a functionality test. I would love to get some review from the community. Thank you. The idea of the system is a simple CLI application which can be used to download PDF from a given ...
user avatar
1 vote
1 answer
78 views

A simple Java integer integer hash set - follow-up 2

(See the previous version.) Now I have this: com.github.coderodde.util.IntHashSet: ...
user avatar
  • 25.6k
1 vote
0 answers
70 views

A simple Java integer hash set - follow-up

(See the previous version.) (See the next version.) After incorporating changes in the previous post, I came up with this implementation. However, I left hashing as it is. ...
user avatar
  • 25.6k
6 votes
4 answers
1k views

A simple Java integer hash set

(See the next version.) The following data structure implements a hash table based set for int values: ...
user avatar
  • 25.6k
5 votes
2 answers
141 views

Hungarian algorithm for optimal assignment

The assignment problem is about assigning tasks to workers, where each pair (worker, task) has a cost. The Hungarian algorithm builds an optimal solution for this problem. It has two variants, ...
user avatar
  • 310
0 votes
1 answer
41 views

Faster, indexed, heuristic doubly-linked list data structure in Java: unit tests

Here I have the unit tests for the indexed doubly-linked list. It goes like this: ...
user avatar
  • 25.6k
1 vote
1 answer
78 views

Unit Tests for the operators of image template class with Boost.Test framework in C++

This is a follow-up question for Tests for the operators of image template class in C++. As G. Sliepen's answer mentioned, I am attempting to use Boost.Test and several test cases are created with <...
user avatar
  • 3,546
2 votes
1 answer
96 views

Conway's Game of Life in a C# class. Is this sensibly factored and well tested?

I'm learning C# and have written the below class to encapsulate the game state of Conway's Game of Life and its update methods. I'm also learning about implementing light automated unit tests for ...
user avatar
  • 31
3 votes
1 answer
213 views

Rigorously checking whether 2 floating point numbers are close in VBA

latest updated version in cross-post from SO I'm testing performance regression of some code I wrote (this is not that code) by timing its execution in Unit tests. I would like to see if execution ...
user avatar
  • 2,040
1 vote
1 answer
51 views

How to make the initialization of the mocks more readable?

In an Arduino project, I'm using some code which is a slightly modified version of a public library. I made several modifications to it: I performed some minor changes I needed to make the code work. ...
user avatar
0 votes
1 answer
73 views

Unit tests for individual methods of a calculator

Recently I needed to expand the exports in a file to all methods in order to allow for Jest tests to cover more of the code (without using Rewire). Beforehand, only the functions used by other ...
user avatar
3 votes
1 answer
563 views

Testing DAO Delete User

I have several Dao classes, including a UserDao, below. The DAOs have many methods, but I'm focussing on deleteUser: ...
user avatar
0 votes
1 answer
158 views

Unit tests for User class with JUnit 5

This is a follow-up question for Android app class serialization. Some problems have been mentioned in forsvarir's answer. Then, I am following JUnit 5 User Guide to redesign the test cases for ...
user avatar
  • 3,546
5 votes
1 answer
66 views

Create a full automation test suite using a mock file

As part of the hiring process (QA position), I received as a homework assignment (which involves independent study) the following task: Create a full automation test suite (in Python3), so that when ...
user avatar
  • 53
2 votes
1 answer
70 views

Android app class serialization

I am attempting to build an Android APP with the custom serializable class User. The public method Save is to save class ...
user avatar
  • 3,546
3 votes
4 answers
94 views

Move an unaligned bit-addressed range into another bitmap

Context I have an array of maximum-fixed-size, size, containers of items; these items are either pointers to objects or an index of the same array, (but no loops.) ...
user avatar
  • 1,015
0 votes
1 answer
1k views

Unit test using mocks

As some part of my application needs connection to database I wanted to create tests that use mocks to avoid running special instance of database just for testing. That gave me a glimpse of how can I ...
user avatar
  • 131
0 votes
2 answers
237 views

Need Feedback on JUnit test comparing two timestamps

I am writng a JUnit test case for the below methods : ...
user avatar
1 vote
1 answer
92 views

BoltDB Lookup and Add methods and advice on unit testing

I am writing a Go package that handles communication with BoltDB as a part of some larger project. I have 2 methods for interacting with DB. ...
user avatar
2 votes
0 answers
48 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 ...
user avatar
0 votes
1 answer
65 views

Unit Test case for services method in angular

I want to write the test case for Service class. My Service Class dynamic-form.service.ts ...
user avatar
5 votes
0 answers
53 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 ...
user avatar
2 votes
2 answers
140 views

Mocking Interfaces Golang

I thought of doing the following to mock/test functions in Go and wanted some advice. Let's say you have an interface for a repository: ...
user avatar
  • 123
1 vote
1 answer
88 views

Conventional C# for LinkedList with (non-)nullable references + xunit tests

I'm new to C# and would appreciate any feedback you might have on the following doubly-linked list implementation, particularly WRT the following language features: Exception handling Debug.Assert ...
user avatar
2 votes
0 answers
29 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'...
user avatar
  • 21
9 votes
5 answers
2k views

Unit test for a maximum-finding function

A while ago, I got this question as a part of an interview test which asked to write a function to find the biggest number in a vector and write all the unit tests required to show that the code works ...
user avatar

1
2 3 4 5
21