As of May 31, 2023, we have updated our Code of Conduct.

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
3 votes
5 answers
107 views

How can I get enough time for unit testing as a developer

I'm always being pushed for feature development and then held to dates that don't give enough time for writing unit tests. What practices can I use to be a better advocate for getting unit tests ...
Michael Durrant's user avatar
0 votes
1 answer
36 views

Automatically testing for typical edge cases?

I want to set up automated testing on my UI components. For anything that renders textual data (i.e. strings or numbers), I would like to automatically test for typical edge cases, such as: Very long ...
Peter's user avatar
  • 109
0 votes
1 answer
70 views

Postman - Compare response body with database data

Request Body: { "StudentInfo":{ "Student":[ { "StudentId":"001" } } } Response Body { "Studentinfo":{ "Student&...
user55906's user avatar
-1 votes
1 answer
47 views

Can you use Azure DevOps Test Plans to discover TDD Unit Tests?

On Azure DevOps, Test Plans, are Test Plans ever used in determining TDD Unit Tests? Quality Assurance may add their own tests later, but initially, during development, is there any reason why the ...
learntofix's user avatar
1 vote
1 answer
44 views

Should I write redundant unit tests for property setters/getters?

Given: I have a policy of writing thorough, automated unit tests for every externally visible element of an application/system. Given: I have an API that includes accessors for a property. The ...
Jack Straub's user avatar
-1 votes
2 answers
37 views

Unit Tests or Integration Tests for validating file contents

I have a Node.js application, and it already has Unit Tests and is using the Mocha framework for the same. It is checking the functions individually. These tests are integrated into the CI/CD pipeline ...
Happy Coder's user avatar
0 votes
0 answers
150 views

How to test RobotFramework test library using mock objects

I have created a RobotFramework test library in Python. It internally utilizes paramiko and paramiko-expect packages to connect to various *nix hosts and execute Unix commands. I have been reading ...
Amit Tendulkar's user avatar
0 votes
0 answers
13 views

How can I check the value of object parameter inside StatusCode response?

Assume we have: return StatusCode(500, new { message= "ApplicationSettings is Null!" }); Now I want to check the message value inside my unit test. How should I do it?
Ramin Bateni's user avatar
0 votes
0 answers
24 views

How to test a TFA library?

I have a Two Factor Authentication library that handles all the crypto necessary to convert a pre-shared secret into a 6 number code used to authenticate. I've followed the standard as tightly as ...
Corey Ogburn's user avatar
1 vote
4 answers
116 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 ...
ssaf's user avatar
  • 21
2 votes
2 answers
49 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 ...
Alvaro Aguilar's user avatar
1 vote
1 answer
164 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 ...
Alvaro Aguilar's user avatar
0 votes
1 answer
288 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(...
Ramin Bateni's user avatar
1 vote
0 answers
46 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 ...
cjones's user avatar
  • 129
3 votes
1 answer
181 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 ...
Ramin Bateni's user avatar
11 votes
2 answers
1k 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. ...
Kirzilla's user avatar
  • 213
1 vote
0 answers
198 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 ...
Al2110's user avatar
  • 129
0 votes
1 answer
63 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 ...
cjones's user avatar
  • 129
0 votes
0 answers
45 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 ...
Francesco's user avatar
  • 101
0 votes
1 answer
261 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 ...
Stefan's user avatar
  • 13
0 votes
1 answer
30 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 ...
Santosh Hegde's user avatar
1 vote
1 answer
66 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 ...
davidtepper's user avatar
1 vote
1 answer
61 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 ...
Null Head's user avatar
  • 119
1 vote
1 answer
40 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) { ...
grunet's user avatar
  • 176
1 vote
1 answer
178 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: ...
meado's user avatar
  • 21
1 vote
1 answer
54 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 ...
Bong2000's user avatar
  • 111
3 votes
3 answers
988 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 ...
Petro Ivanenko's user avatar
1 vote
1 answer
97 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 ...
Petro Ivanenko's user avatar
1 vote
1 answer
151 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 ...
Moorpheus's user avatar
  • 255
2 votes
1 answer
1k 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 ...
Mohannad Maklad's 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 ...
Kosh's user avatar
  • 315
0 votes
0 answers
41 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. ...
Morgan Courbet's user avatar
1 vote
1 answer
110 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 ...
Eric's user avatar
  • 205
4 votes
1 answer
154 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 ...
Eric's user avatar
  • 205
5 votes
1 answer
65 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 ...
rockfort's user avatar
19 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) ...
Sahil's user avatar
  • 291
1 vote
0 answers
2k views

pytest one time teardown after all tests in all modules have run

I have a directory with a bunch of modules. Each module has a bunch of specific tests. I know how to teardown after methods, classes and modules. What am trying to do is teardown after all the tests ...
Aziz's user avatar
  • 161
2 votes
2 answers
45 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?
Rasshu's user avatar
  • 129
5 votes
1 answer
123 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 ...
FDM's user avatar
  • 5,904
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 ...
Prashant Pandey's user avatar
1 vote
0 answers
59 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 ...
Raph Schim's user avatar
5 votes
3 answers
135 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 ...
ElkCor's user avatar
  • 63
3 votes
1 answer
206 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,...
PiotrK's user avatar
  • 133
7 votes
2 answers
842 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 ...
Jarryd's user avatar
  • 179
3 votes
1 answer
103 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 ...
Eric's user avatar
  • 205
1 vote
2 answers
80 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 ...
Joe's user avatar
  • 121
0 votes
3 answers
159 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 ...
Mornon's user avatar
  • 1,107
6 votes
1 answer
530 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, ...
es.i's user avatar
  • 61
2 votes
1 answer
56 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 ...
MrJalapeno's user avatar
0 votes
1 answer
451 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 "...
Nzall's user avatar
  • 475

1
2 3 4 5