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
vote
1answer
17 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
2answers
94 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
1answer
31 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
votes
1answer
49 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
1answer
75 views

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

(See the previous version.) Now I have this: com.github.coderodde.util.IntHashSet: ...
1
vote
0answers
60 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. ...
6
votes
4answers
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: ...
5
votes
2answers
110 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, ...
0
votes
1answer
37 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: ...
0
votes
1answer
54 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 <...
2
votes
1answer
78 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 ...
3
votes
1answer
153 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
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. ...
0
votes
1answer
56 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
245 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
106 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 ...
5
votes
1answer
65 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
64 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 ...
3
votes
4answers
91 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
267 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
114 views

Need Feedback on JUnit test comparing two timestamps

I am writng a JUnit test case for the below methods : ...
0
votes
0answers
98 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
58 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
39 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
48 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 ...
5
votes
0answers
43 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
88 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
74 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
26 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
48 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
72 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
69 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
37 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
79 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
74 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
74 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
165 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 ...
2
votes
0answers
36 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
45 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
33 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
73 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
97 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
37 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
67 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
74 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
141 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
130 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 ...
7
votes
1answer
181 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
24 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 ...

1
2 3 4 5
21