Questions tagged [unit-testing]

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

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

Generate INSERTs from function parameters with jinja2

I'm writing unit-tests with pytest for sqlite database and reporting functions and I need to arrange them by inserting minimal ...
  • 44k
4 votes
1 answer
59 views

Blocking Queue Class Unit Test

I would like any feedback on making the unit test for a BlockingQueue class more robust or better? improvements to the coding style, use of the ...
  • 205
2 votes
1 answer
82 views

A singly linked list implementation

Here's yet another implementation of a singly linked list. You may base your review on the following questions: Review goals: Is the API well thought of? Does this design include undefined behavior, ...
  • 929
0 votes
0 answers
26 views

Manage Access Control on Swift UI Elements

I have following ViewController class with a tableView. ...
-1 votes
1 answer
51 views

Test the log in functionality of a web page with incorrect credentials [closed]

I'm new to playwright, so I'm unsure if this is the correct or best way to go about testing. I basically want multiple tests on the same webpage. I've been able to successfully accomplish this using ...
  • 3
0 votes
0 answers
31 views

contextmanager indenter package and test suite

I would like to learn Python packaging and testing best practices. I wanted to gain experience with packaging and testing, and also play around with context managers, so I made a contextmanager that ...
0 votes
1 answer
45 views

Protein Translation Learning Exercise from exercism.org

I'm learning Rust by solving exercises from different tracks on Exercism. The below code is an implementation of "Protein Translation" from the Python track. I split ...
  • 435
0 votes
1 answer
70 views

Unit testing and alternative to mocking in Haskell

Let's say you have a simple pure function that applies a discount of 30% if the total price of a list of Items is over 30.00 (let's not delve into the fact that I'm ...
  • 201
0 votes
0 answers
22 views

Java pathfinding in general trees - Part 4/4: unit tests

Java pathfinding in general trees - Part 1/4: model classes Java pathfinding in general trees - Part 2/4: algorithms Java pathfinding in general trees - Part 3/4: demonstration Java pathfinding in ...
  • 26.5k
1 vote
1 answer
48 views

N dimensional array index utility Improved

This is a continuation from a previous question; I updated the code with the suggestions and added an additional iteration. Templates are not an option because of the usage: The objects are stored as ...
3 votes
2 answers
597 views

Clean up directories and files when a unit test fails

While running unit tests (most of them integration tests) with Python I create some directories. They need to be deleted after the test or when the test fails. The execution of the cleanup code need ...
  • 197
0 votes
0 answers
342 views

Unit testing / TDD MediatR Queries and Validators

I would like to get a code review for the following code. It's meant to filter mocked products. I used to not like writing tests, but some time ago I realized how great TDD is. Not only it makes the ...
  • 677
0 votes
0 answers
19 views

Unit test for a user search React component

I am trying to improve myself in unit test. Here is my code and test. Should I define mock function? I felt like I was controlling too many details. Is there a better way to write this? Component: <...
  • 11
4 votes
1 answer
546 views

Transliterate between Cyrillic and Latin scripts

I want to get a code review on the following transliteration code. I wrote it because there were some libraries that I have tried and they were specifically failing with the name "Yuliya" ...
  • 677
3 votes
0 answers
131 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 ...
4 votes
2 answers
450 views

Unit testing for a multi-dimensional array class

I have designed a class bunji::Tensor which is a multi-dimensional array. I have designed it to have a similar interface to a multi-dimensional ...
4 votes
1 answer
49 views

Python unit tests for storing and loading objects

I wrote some code and thought I may get better with some feedback. I program for almost 5 years, mainly in python. I care most about the unit testing. I am not really sure, how industry standard unit ...
  • 41
0 votes
0 answers
46 views

Unit test for a registration form using C# and Selenium

I would like to know if the below code written in C# Selenium to do Unit Test is efficient and readable. Is there any particular way to do Unit Test. Else suggest me where I can learn to do better ...
  • 1
2 votes
2 answers
113 views

Astronomical calculations in C for python bindings

I've started teaching myself c/c++ with the intent of being able to writing python bindings to c code. I have a c library used ...
3 votes
1 answer
72 views

Unit test for a React click-counting component

Take this basic component using state: ...
0 votes
0 answers
243 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 ...
  • 185
3 votes
1 answer
85 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 ...
  • 3,768
1 vote
0 answers
43 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 ...
  • 527
1 vote
0 answers
45 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 ...
1 vote
2 answers
76 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 ...
2 votes
0 answers
45 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
69 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 ...
  • 111
0 votes
0 answers
780 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'...
2 votes
1 answer
93 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 ...
0 votes
0 answers
202 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 ...
  • 293
3 votes
3 answers
256 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 ...
  • 140
1 vote
1 answer
170 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 ...
  • 619
2 votes
0 answers
28 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: ...
2 votes
1 answer
266 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. ...
0 votes
1 answer
67 views

First time writing tests (Service Layer)

Service class: ...
  • 51
0 votes
1 answer
96 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 ...
  • 751
1 vote
0 answers
51 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 ...
2 votes
1 answer
145 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 ...
  • 3,768
0 votes
1 answer
100 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 ...
  • 751
1 vote
1 answer
29 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 ...
0 votes
2 answers
116 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 ...
0 votes
1 answer
81 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 ...
  • 3,850
3 votes
1 answer
64 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 ...
1 vote
1 answer
83 views

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

(See the previous version.) Now I have this: com.github.coderodde.util.IntHashSet: ...
  • 26.5k
1 vote
0 answers
74 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. ...
  • 26.5k
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: ...
  • 26.5k
5 votes
2 answers
180 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, ...
  • 365
0 votes
1 answer
46 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: ...
  • 26.5k
1 vote
1 answer
140 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 <...
  • 3,768
2 votes
1 answer
130 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 ...
  • 31

1
2 3 4 5
21