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
2
votes
0answers
108 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 ...
1
vote
1answer
46 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. ...
0
votes
1answer
47 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 ...
3
votes
1answer
70 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: ...
0
votes
1answer
97 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 ...
4
votes
1answer
63 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 ...
2
votes
1answer
58 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 ...
2
votes
2answers
53 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.) ...
0
votes
1answer
55 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 ...
0
votes
2answers
87 views

Need Feedback on JUnit test comparing two timestamps

I am writng a JUnit test case for the below methods : ...
0
votes
0answers
38 views

TypeORM EventSubscriber unit testing

I've been playing with TypeORM and I wanted to create proper tests for my EventSubscriber. I also wanted those test to be independent from database connection. I believe I managed to achieve my goal. ...
1
vote
1answer
21 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. ...
2
votes
0answers
32 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 ...
0
votes
1answer
41 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 ...
4
votes
0answers
36 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 ...
2
votes
2answers
69 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: ...
1
vote
1answer
66 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 ...
2
votes
0answers
23 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'...
9
votes
5answers
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 ...
4
votes
0answers
45 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 ...
2
votes
2answers
68 views

Python unit testing

I have started a hobby project and would like to integrate better and more thorough testing practices. Since I am not too used to it, I'd love to have some feedback on the sample code below. In ...
-1
votes
2answers
61 views

Should I add optional parameter to my function for test cases? [closed]

I have the function below, I want to access the context globally and I don't know if it's a good idea, I'm getting the context from the Application, I have TestAppliction in the test environment and I ...
2
votes
0answers
29 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 ...
3
votes
2answers
72 views

Replace words from a file with words from a dictionary based file

I'm working on a coding challenge that tasks me with taking a file with a dictionary, reading from it, and then replacing the matching words from the input file with what is found in the dictionary. I ...
-2
votes
1answer
70 views

Testing Code That Has Time Delays [closed]

Whilst refactoring an app I'm working on I moved a piece of code from the business logic layer to a helper. The code in question is a fire and forget method that will execute a piece of code if it ...
2
votes
1answer
63 views

Using pytest fixtures for the expected answers to a test?

I want to test a number of different functions I have written to solve the Fizzbuzz challenge and would like to know what is the best way to check the result? Each function returns a list of the ...
4
votes
2answers
159 views

Are these Unit tests OK or am I implementing an antipattern or not following best practices

I am testing a Spring boot service using JUnit 5 and Mockito. I haven't spent much time on unit testing in the past so I'm not sure if I'm accidentally implementing an anti-pattern or not following ...
1
vote
0answers
31 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 ...
2
votes
1answer
41 views

Portable Build System for Virtual Machine with Editor and Unit Tests

I am automating the building and unit testing of a personal project using shell scripts , CMake and make on the latest version of Fedora Linux. I have also tested building on the latest version of ...
2
votes
0answers
30 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: ...
1
vote
1answer
71 views

What to test on a rest API?

I created a rest controller with Spring Boot, I am trying to learn what I should write on my tests, right now I only check status codes and keys existence. I am planning to build an API to showcase at ...
0
votes
1answer
90 views

Is this enough for unit testing a basic controller?

My pet project, is a community driven lyrics archive, it is still a work in progress, and all code is open sourced on GitHub. I have a local git branch ...
1
vote
1answer
32 views

Testing Remedy-on-Demand REST API code

I am writing a python module to interact to the ROD (remedy on demand) BMC ticketing product. So far I have only written the log in and log out methods and tests. Before I crack on with the more ...
5
votes
1answer
66 views

Writing unit testing for conference management class

I try to use unittest for conference class, but I am not sure that I have considered all condition or more complex tests should be added? conference.py ...
0
votes
0answers
69 views

Various Type Test Cases for recursive_transform Template Function in C++

This is a follow-up question for Nested std::deque and std::vector Type Test Cases for recursive_transform Template Function in C++, A recursive_transform Template Function Implementation with ...
5
votes
1answer
136 views

A Various Container Type Arbitrary Nested Iterable Generator Function Implementation in C++

This is a follow-up question for std::array and std::vector Type Arbitrary Nested Iterable Generator Functions Implementation in C++ and std::deque and std::list Type Arbitrary Nested Iterable ...
6
votes
1answer
122 views

Non-nested std::deque and std::list Generator Function for arithmetic_mean Function Testing in C++

This is a follow-up question for A non-nested test_vectors_generator Function for arithmetic_mean Function Testing in C++ and An arithmetic_mean Function For Various Type Arbitrary Nested Iterable ...
8
votes
1answer
159 views

Generic test case templates

I often find that when I am writing, refactoring, or reviewing code that I want to do some simple testing. There are many existing test frameworks such as gtest and cppunit but my desire was to ...
2
votes
0answers
23 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 ...
2
votes
1answer
156 views

Testing a template function in GoLang using mocking - making it DRY & easy to follow

TL;DR I'm wondering how to organise test functions using mocks for GoLang drier & easier to follow. Function I have a template function that is very similar to ACF's getField: It take's in a ...
5
votes
1answer
141 views

Hackerrank: Breaking the records

I'm learning Clojure and am a rank n00b at it, trying to learn from books and online tutorials (but I'm sometimes concerned that I am picking up bad habits or at least not all the good habits). For ...
3
votes
0answers
52 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 ...
3
votes
0answers
193 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 ...
8
votes
1answer
1k views

Testing lower- and upper bound values in Python

Code functionality The following code tests whether the values that a user specifies for a lower bound and upper bound on two properties: The lower bound is smaller than the upper bound. The values ...
1
vote
0answers
25 views

Microservice unit testing database script insert Error - H2 [closed]

For unit testing my ProductList service, I tried run a script to insert some data and then try to get this data and compare the list size. But my database insert script is not running and returns null....
5
votes
2answers
181 views

Complex Numbers & Unit Tests in Python

I've just started a course that will require knowledge and experience with Python for future projects, which I don't have, so I thought I'd give it a go to familiarize myself with it and get some ...
5
votes
2answers
80 views

Ray implementation

Problem Statement/Context: Represent a ray, given a origin and direction. Besides this a min_t and max_t value are defined. ...
1
vote
1answer
159 views

Test django URLs

I started learning Django and now I want to write some tests for my application. After reading some blog posts and watching youtube tutorials I wrote tests for URLs. Look at below. urls.py ...
2
votes
2answers
79 views

Common Unit Testing Code – Follow Up

This question is a follow up question to the Common Unit Testing Code portion of my lexical analyzer questions. My primary concern is the code in the header file and the C source file that implements ...
2
votes
0answers
57 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 ...

1
2 3 4 5
20