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
3
votes
0answers
39 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 ...
2
votes
1answer
20 views

Haskell Hspec/Quickcheck test for numeric function

I'm learning to use HSpec and QuickCheck. As example I was implementing the Pseudocode from Wikipedia:Extended Euclidean Algorithm. You can find the project at github for the implementation of the ...
5
votes
3answers
93 views

CAN Bus testing

I am creating a Python 3.8 script that executes a series of tests that reads and writes information to and from a CAN bus network. I'm using the python-can and the cantools packages. I've managed to ...
1
vote
0answers
22 views

Cypress tests for Monopoly

I am creating Monopoly using react hooks. I am using cypress for testing it. The first test I have to create is to check about dice rolls. I have three tests in which I am repeating the same kind of ...
4
votes
2answers
61 views

Mock Atm program basic functions and xUnit unit test

For self learning purpose, I have created some xUnit unit test for these 2 Atm classes. At the moment, data is store in the in-memory object. This version is extended from previous version. For ...
0
votes
1answer
22 views

Testing Depth First Search Using Pytest

I have an implementation of depth first search, which I want to test using the pytest framework. I would be making test cases for other graph algorithms, and would ...
1
vote
0answers
37 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 ...
3
votes
1answer
93 views

In Memory Database in Unit tests, isolate the tests

I have stumbled across these unit tests in a code review that are using in memory db: ...
3
votes
1answer
118 views

Is this a good unit test for testing three types of mappings all at once?

This question is related to my previous two questions, in which I have implemented HashTable, and also SortedListMap and ...
4
votes
2answers
100 views

Sanity check a simple RPG character

I'm writing an assistant for the tabletop RPG Pathfinder in Java. I intend to use the MVVM pattern using JavaFX, possibly through mvvmFX. Before I go into the V-VM phase, I have built a first ...
1
vote
3answers
59 views

high card game implementation

I wanted to write a simple implementation for a high card game. Basically two cards are drawn and the higher one wins. Additional rules: support for multiple decks, if same suits drawn then the ...
5
votes
1answer
144 views

Multiplayer card game “Hearts” with OOP in Python

To practice Object-Oriented Python and learning how to write tests, I found an exercise and solved it as below(all classes are put in one block of code to make the question a little bit more readable):...
4
votes
3answers
127 views

DistinctCount extension method

Here I go again. I have been finding a fairly common pattern in business logic code. And that pattern looks like this: ...
4
votes
0answers
32 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 ...
1
vote
0answers
24 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 ...
9
votes
1answer
134 views

Secure ADODB: Unit of Work

I've been meaning to revisit this old code for a long time, and this week finally ended up doing it. The resulting code is on GitHub, and for full context and disclosure I wrote a blog article about ...
4
votes
2answers
107 views

Increment values in a dictionary

In my continued venture to teach myself C# I came across an exercise using Dictionary. I created a class that has a method. In that method it creates a dictionary with keys/values. A string is ...
4
votes
4answers
76 views

PropertySet implementation

Problem Statement: Store properties with a certain name (key), type and value. The key is always a character literal and the value can be of type bool, ...
0
votes
0answers
14 views

Parametrize pytest test suite to work for mutiple classes

Context: I am working on a package which lets users access credentials (stored with a defined structure) from a database. The "database" can be a real KeePass database or other text based formats like ...
3
votes
2answers
84 views

Unit testing Roman-Arabic-Roman numeric converter

As you can see here, I wrote the methods public static int romanToArabic(String number) and ...
4
votes
1answer
38 views

Correct way to unit-test express API

I wrote an express API for a document management service (repo to be found here) and even though I understand the importance of unit-testing I never quite managed to wrap my head around how I would ...
-2
votes
1answer
19 views

How to test that an event will not be fired in xUnit? [closed]

I have two questions. Does it make sense to test that an event will not be fired? If yes, what is the best way to accomplish that using the xUnit framework? For ...
-1
votes
1answer
24 views

Unit Testing - test deletion of archived files [closed]

I am writing unit test for this function - ...
3
votes
1answer
57 views

Testing Terminal Text Game with Classes and Game Loop

I am making a super simple and dumb terminal text game to try out unittest in python. I have ran into a problem. When I run the test, the game loop is ran, and I have to manually insert input to ...
10
votes
3answers
2k views

Secrets management, operational security, keeping API tokens hidden while streaming

I've taken up code streaming and I'm concerned that as I do so, I'll leak an API token somewhere. It was suggested that I use something like "a secrets.toml or secrets.yaml or secrets.json file." But ...
2
votes
1answer
48 views

First attempt at Mars Rover Kata done in TDD

I have had an attempt at the Mars Rover Kata and would very much appreciate a review and any suggestions to improve. MessageParser to parse incoming messages and create the domain models: ...
3
votes
2answers
75 views

Integer index based Union Find with path compression strategy

I've created an integer index based union find implementation in C#, and am looking for some feedback. Unit tests have been written with NUnit. Some questions I am considering: Can the implementation ...
0
votes
1answer
45 views

Possible Test Cases in Tester [closed]

I am trying to write a human-readable tester for a functioning program. There are four methods in the class Polynomial: ...
13
votes
4answers
3k views

Unit testing Video Service class

I wrote my first unit testing code on a service class using Mockito. The code looks like this: ...
6
votes
4answers
211 views

All your Base - Exercism.io

This is an exercise on the website Exercism. I am self taught trying to learn C# and C++. This is the information from the readme. Convert a number, represented as a sequence of digits in one base,...
1
vote
1answer
52 views

Decoupling of validation and data access in ASP.NET

I've been asigned to a project no dev has touched in a long time. It's an ASP.NET MVC 4 application. It appeared to be well coded, but had no testing and the database migration folder is not present. ...
1
vote
1answer
80 views

Unit testing a commands class

...
4
votes
4answers
131 views

Statistics Library with Sample, SampleBuilder and Tests

Introduction I'm working on a Statistics Library that can record observations and produce a Summary of the statistics when there's enough observations. Right now, it's at its early stages and is ...
6
votes
1answer
98 views

Vue component for Game Die (dice)

As part of learning Vue and Vue Test Utils I develop some simple games. I made a simple version of craps. Because in many other games a die (or dice) is used, I decided to create a reusable component <...
9
votes
4answers
961 views

Building string with max length

I need to run a evaluation for large (1 Million) number of components and build a string with error which has comma separated error codes. As the final string is to be persisted in RDBMS TABLE.COLUMN ...
4
votes
2answers
409 views

Mocking pathlib.Path I/O methods in a maintainable way which tests functionality not implementation

I have a function that constructs a path based on a function of inputs and creates the parent directory. When writing a unit test for this function, I want to mock the I/O part of the function, ...
-2
votes
2answers
88 views

Episode 1: Mastering code and Testing it [closed]

Once upon a time there was a noob developer who learned it all by himself because he grew up in a nation far behind in IT. I've tried to learn C# for about 5 years, without any improvement over the ...
0
votes
1answer
94 views

Asking for test: Calculator function javascript

I have made a code that can run a calculation from text. When I tested it, I didn't find any bugs. You are sharper than me. Maybe you can discover some bugs in this code. When you know some ...
0
votes
1answer
67 views

Unit testing an unspecific order of method calls [closed]

I cannot figure out how I am supposed to unit test the implementation of GetFilteredEntites(IEnumerable<MyEntity> myEntities). ...
3
votes
0answers
169 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 ...
1
vote
0answers
28 views

Document storage models and Django Unit Testing

My question is about proper testing procedures for Django models. The project is for a startup building a very basic HR system due to excel sheet data integrity problems. I am trying to figure out the ...
5
votes
2answers
232 views

Test on remove function

let's say I want to create a 'utils' package with several functions working on files and folders. I want to do it once properly so I can use them in all my personal projects without feeling to re ...
3
votes
1answer
58 views

Basic Unit Test of Application Service, setup and cleanup methods

I'm not experienced with testing, therefore I'd like you to look at my code proposal of unit test. My solution has following projects Tests\Application.Tests Application Domain Infrastructure Web ...
11
votes
4answers
2k views

Binary Search given sorted array Unit test

I have implemented Binary search code for a given sorted array, written unit test too, Please review my BST unit test code and let me know your comments for improvements. ...
0
votes
0answers
59 views

More assertions about data in infrastructure code as unit tests

This question is related to this other one that I asked yesterday. I have some Python code to make assertions about YAML data in AWS CloudFormation templates as follows (simplified): ...
2
votes
1answer
45 views

Assertions about data in infrastructure code as unit tests

I have some Python tests I have written, but these are for making assertions about data in infrastructure code (AWS CloudFormation templates). I am using the Unittest framework. I have code like this:...
4
votes
0answers
70 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 ...
13
votes
0answers
162 views

Open source project to ease the Assert part from the functional tests of .Net Core Web APIs

I have built an open-source project based on FluentAssertions in order to solve some recurring tasks I was doing while testing the .Net Core APIs I'm developing. I find the capability of doing in ...
1
vote
1answer
139 views

Unit Test class from iOS

I am learning to write test cases in iOS using Swift. I was stuck at testing static functions from my Utilities class, so I ...

1
2 3 4 5
19