Questions tagged [unit-tests]

Unit testing is a method by which individual units of source code are tested to determine if they are fit for use. A unit is the smallest testable part of an application.

Filter by
Sorted by
Tagged with
1 vote
4 answers
91 views

Is software unit testing with tools considered manual or automated?

I'm quite new to software testing. I was studying about it and I've read testing can be either manual or automated. So is unit testing with tools (e.g. unittest or pytest in python) considered manual ...
user avatar
  • 21
0 votes
0 answers
58 views

C++ Boost test header-only variant - linker error when trying to use multiple translation units

I have the following project structure: +-namespace1 | | | +-foo.cpp | +-foo.h | +-namespace2 | | | +-bar.cpp | +-bar.h | +-main_test.cpp | +-...
user avatar
  • 129
2 votes
2 answers
46 views

Unit testing for a non-atomic function if all atomic components have been tested

I am writing a module and I have a question about the best way to test a "non-atomic" function. My problem is that I am not sure how much and what specifically I should test because it being ...
user avatar
1 vote
1 answer
31 views

Unit testing function that reads from pdf - Having dedicated external files?

I am relatively new to automated testing and although I understand the basics to be able to "do it" I don't know much about what are best practices and why. Specifically I am trying to ...
user avatar
0 votes
0 answers
50 views

How to write shim for ExecuteReaderAsync?

I have the following method and want to write shim for the needed functionalities in it include ExecuteReaderAsync: public async Task<IEnumerable<ApplicationSetting>> LoadSettingsAsync(...
user avatar
1 vote
0 answers
35 views

Delineating unit tests and integration tests in Testing Library for React and unittest

This question is related to Testing Library for React and unittest for Python. I'd like like to have a single file that contains unit tests and integration tests for a component, and be able to target ...
user avatar
  • 129
3 votes
1 answer
51 views

In unit tests, should I check all null and invalid child properties in the input arguments that cause error and force developers too?

In a large application, I have a lot of methods with input arguments that each argument is a model with nested models (as you see in the image). You see that I have written some conditional codes and ...
user avatar
10 votes
2 answers
637 views

Should integration tests test business logic?

In unit tests I'm always trying to test as many business cases as possible, trying to reach 100% code coverage. Unit tests are great and pretty simple because all tests are made in isolation. ...
user avatar
  • 203
1 vote
0 answers
84 views

Java Swing MVP unit testing with Mockito

Description I have a simple Java Swing application implementing the Model-View-Presenter pattern. My aim is to be able to test the logic behind "rendering" the view. Here is the presenter ...
user avatar
  • 129
0 votes
1 answer
44 views

Sorting out automated testing in CI pipeline and getting conflicting information related to building, unit testing and Docker images

I seem to get a unique response for every person that I ask, or every article that I read, which is just confusing me even more. Basically, I'm trying to setup automated testing in the CI pipeline ...
user avatar
  • 129
0 votes
0 answers
44 views

Is mock data in unit tests feasible?

I am implementing an abstraction layer that basically translates Hibernate criteria into my data model. I am trying to apply TDD but test fixtures are Hibernate criteria objects, hard to get without a ...
user avatar
  • 101
0 votes
0 answers
41 views

Unit Testing in C++ CLI Windows Forms Application

I have built an application using C++ CLI in Windows Forms Application. I need to create unit tests for this. I tried searching everywhere on the internet but nowhere there is a way to do it. ...
user avatar
0 votes
1 answer
69 views

Unit vs Component vs System Testing [duplicate]

Can somebody explain the difference between unit, component, and system testing with a real example. What I understand is unit testing is about testing individual functions with mock services if the ...
user avatar
  • 13
0 votes
1 answer
23 views

How to test functions which interacts with databases?

I have a function getEmployeeData() which internally calls generateSQL() to get the SQL and execute it and returns the final result. Now, how to test this functionality? Having JUnit test to validate ...
user avatar
1 vote
1 answer
64 views

How are execution conditions and testing procedures traits of an test case for an unit test?

Wikipedia link about what a test case describes a test case as: a specification of the inputs, execution conditions, testing procedure, and expected results that define a single test to be executed ...
user avatar
1 vote
1 answer
44 views

Should I push my changes for testing and then work on unit tests?

Say I am working on a React app, in Agile methodology. I pick up a story. Do the dev work sans unit tests. Push it to the testers for picking up when they are ready. In the meanwhile, I start writing ...
user avatar
  • 119
1 vote
1 answer
31 views

How do you test (currently) unreachable code?

I have a function that needs to do something like "try to move to node X in a directed graph", and my current implementation uses an indefinite loop like this while(true) { ...
user avatar
  • 56
1 vote
1 answer
58 views

validated variable is present and datatype assertion using Jest testing

I have 2 files as below admin.js const mongoose = require("mongoose"); const Schema = mongoose.Schema; const Schema = new Schema({ User: { type: String, unique: true }, Pass: { type: ...
user avatar
  • 21
1 vote
1 answer
44 views

What is the correct way to test classes in Python?

There is a class named State that has several attributes, which I need to write unit tests for. The test will need to have certain actions that change attribute values of the State instance. Expected ...
user avatar
  • 111
3 votes
3 answers
516 views

Code coverage for Integration tests

Let's say that I have a project where most of the codebase is already covered with Unit Tests (using mocks). How many Integration Tests should I write then? The entire codebase is already covered with ...
user avatar
1 vote
1 answer
66 views

Integration tests without mocking vs. unit tests

Let's say that I have a software component A (function, class, react component, etc.) that uses three other software components B, C, D. If I try to test fully test A (without mocks!), then I would ...
user avatar
1 vote
1 answer
99 views

Accessibility testing at the unit level

I know there's plenty of tools out there to look at a fully available web page for accessibility issues, but what about for doing earlier unit testing? The application I'm testing involves Angular and ...
user avatar
  • 255
2 votes
1 answer
798 views

What is the best way to unit-test a state machine?

I love state machines because they have systematic ways to test it but i would like to discuss some philosophies with you. Referring to the upper state machine, Suppose that we always start a state ...
user avatar
7 votes
5 answers
1k views

Should QA test features that are already covered by developers (according to what they say) with unit tests?

Should QA test features that are already covered by developers (according to what they say) with unit tests? From the one point of view it could save time, from the other - after all many developers ...
user avatar
  • 315
0 votes
0 answers
38 views

How to unit test global validation?

Let's say my program takes two required arguments: --opt-a and --opt-b. I want to test every single validation: two test cases here, one if --opt-a is missing, and another one when --opt-b is missing. ...
user avatar
1 vote
1 answer
88 views

Are Characterization (Golden Master/Snapshot) tests supposed to be human readable?

I am trying to write characterization tests, in order to quickly put a legacy system to a test harness. I was not able to find many examples with production code. The examples I find are small ...
user avatar
  • 205
4 votes
1 answer
116 views

How to create input data for unit tests for an API client?

I am building the initial set of unit tests for my team's legacy API client system. We have been writing integration tests, but have no unit tests. It's a Sinatra server that accepts requests from our ...
user avatar
  • 205
5 votes
1 answer
61 views

How to choose between shell script vs compiled, from testing perspective

There is a small program I had to create for some basic data conversion/gateway functionality (network download from one place, text manipulation, network upload to some other place). Because this ...
user avatar
20 votes
5 answers
4k views

Is it good practice to write unit tests when features are changed frequently?

Should I write the unit test cases for a frequently changing product? For example: I start the project with Phase 1 (say it's 6 months long) and I know there will be a phase 2 (3-4 months or more) ...
user avatar
  • 301
2 votes
2 answers
42 views

If I intend to do automated tests in a project e.g. Cucumber, are unit tests needed e.g. JUnit?

It seems to me it's doing the same job twice, one with mocks and the other without them. Could anyone explain why it's right or wrong?
user avatar
  • 129
5 votes
1 answer
106 views

Unit testing - how to decide if (and how) we need to invest more in unit testing?

As a tester, I've been asked to provide some concrete input regarding unit testing - with regards to the overall product and process quality. Our current situation is as follows: Organisation has ...
user avatar
  • 5,834
0 votes
2 answers
60 views

Writing Better Stubs To Local Behaviour Testing

I have recently faced an embarrassing bug in PPE and want to improve my testing strategy so that I can mitigate such bugs in future during local testing itself. I have an API that interacts with a ...
user avatar
1 vote
0 answers
50 views

Unit test for reading/writing files

I finished my studies recently and I am a junior developer. The problem is that I'm the only computer scientist in my company and I am afraid of taking bad habits because nobody is here to tell me how ...
user avatar
5 votes
3 answers
129 views

Is unit testing related only to software development?

I have searched for "Unit test" on the internet and I always find that it is a software development topic. If I am not writing code and instead I am designing, for example, a BI dashboard, can I ...
user avatar
  • 63
3 votes
1 answer
167 views

Random code changes - terminology and tools

Someone told me that the unit tests are good when you change something in the code under test, and the tests detect it (they fail). The changes can focus on introducing common errors, like off-by-ones,...
user avatar
  • 133
7 votes
2 answers
304 views

Best practice guide for documenting unit tests?

A set of a unit tests for a project 3+ years old, now fail. It seems the tests themselves have become out of date, and I've wasted time trying to find non existent bugs. To prevent this happening ...
user avatar
  • 179
3 votes
1 answer
88 views

What should be unit tested in an API client?

I've been reading about unit testing day in, day out for a few days and the more I did, the more frustrated I became. The System Under Test is essentially a client calling external APIs that take XML ...
user avatar
  • 205
1 vote
2 answers
77 views

What is Travis CI usage beyond unit tests and UI tests?

I'm learning iOS development, and started learning Travis CI. Currently, I have it testing unit tests and UI tests, I understand how this can be helpful for a team working on the same project, but ...
user avatar
  • 121
0 votes
3 answers
134 views

How to provide Product Owner with estimates for unit testing?

"How long does it take his developer to write a unit test?" This is exactly the question the project owners keep asking me. The question is not actually how long it takes to write the unit test, but ...
user avatar
  • 1,165
5 votes
1 answer
405 views

Equivalence classes for password strength meter

As an example of password strength meter I use the code from GitHub. Firstly, it calculates the score by adding or deducting points according to the length, whether a password contains numbers, chars, ...
user avatar
  • 51
2 votes
1 answer
54 views

Testing a function where the output is mostly relying on helper functions

Let's say I want to test this function: foo(input){ a = bar(input) if(a) return baz(0) return baz(1) } (pseudocode) I want to test foo in isolation, so i mock bar and baz, but if I ...
user avatar
0 votes
1 answer
300 views

Should unittest assertion values be hardcoded or can they be references to source code variables?

Heavily simplified example that I'm trying to make language agnostic: I have an XmlView Object that has a constant property FACTORY_NAME labeled "factory" and a constant property VIEW_NAME labeled "...
user avatar
  • 475
1 vote
1 answer
238 views

Writing different tests for different environments

We didn't implement automated deployment yet to our Angular 7 project, so environment-based variables (e.g baseUrl) are changed manually, causing the application to crash after deployment a lot due to ...
user avatar
0 votes
1 answer
441 views

Eclipse C++ Unit Testing without Unit Testing framework

I am looking for some ideas on how to implement a Unit Test framework without any existing unit test tools like Google Test Runner. I am on a closed network without internet access and so whatever ...
user avatar
1 vote
3 answers
781 views

Unit Test - Testing API Methods

I was reading the following article Unit testing an API This article is about unit testing an API and the methods on a class through the interface. What I do not seem to grasp is the fact that in my ...
user avatar
  • 119
2 votes
1 answer
1k views

Should I write unit tests when the json schema is validated by a 3rd party library

I have some json data and I would like to validate the data against a defined json schema. I'm using the ajv library for the validation. On the json schema, there are constraint you can specify like ...
user avatar
  • 123
5 votes
2 answers
891 views

Automated testing of single page app

I'm working on a single page app and looking into automated testing of the application. The GUI is generated only from JavaScript + css (document.createElement…) All data communication between server ...
user avatar
  • 150
0 votes
1 answer
1k views

How can I use Sequential attribute with TestCaseSource in nUnit?

I'm new to unit testing and nUnit in general and I'm not sure what I'm trying to do is possible or if I'm using the right syntax (in C#). I want to pass for a test a collection of IEnumerable using ...
user avatar
4 votes
3 answers
210 views

Developers don't write enough or good unit tests, how to address?

Many developers still not seem to the the value and need for unit tests. What might be are the reasons for this so we can address it?
user avatar
-1 votes
2 answers
151 views

Do you test methods that return queries from the database?

I just want to know if you test the output of a query with unit testing. Is this considered good practice? For example you have a method getUsers() getUsers(){ // Overly simplified return ...
user avatar

1
2 3 4 5