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
2
votes
2answers
72 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 ...
1
vote
1answer
34 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 ...
1
vote
1answer
37 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 ...
0
votes
0answers
28 views

Testing strategy for Angular Project

I am working on a software project with Angular in frontend and Spring Boot in backend with a friend. As I am responsible for the frontend, I would like to ask you for you opinion, how to properly ...
1
vote
1answer
54 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 ...
6
votes
5answers
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 ...
0
votes
0answers
29 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. ...
1
vote
1answer
38 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 ...
4
votes
1answer
74 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 ...
5
votes
1answer
56 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 ...
0
votes
0answers
23 views

iOS CI/CD service for Gitlab onpremise

Currently, as continuous-integration / deployment environment, we use a Mac-Mini connected to our Gitlab “on premise” that build, execute unit / UI tests and deploy our iOS applications to firebase, ...
1
vote
0answers
34 views

Unit testing a native sql query

The project in question runs on Hibernate 5.4 for persistence, against MySQL when deployed. Unit tests are ran during the Maven build. I'm in the process of doing a feel-faster optimization. As such, ...
18
votes
4answers
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) ...
2
votes
2answers
40 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?
5
votes
1answer
88 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 ...
0
votes
2answers
52 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 ...
1
vote
0answers
47 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 ...
5
votes
3answers
119 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 ...
3
votes
1answer
147 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,...
7
votes
2answers
76 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 ...
3
votes
1answer
80 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 ...
1
vote
2answers
65 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 ...
0
votes
3answers
106 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 ...
5
votes
1answer
204 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, ...
2
votes
1answer
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 ...
0
votes
1answer
130 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 "...
1
vote
1answer
188 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 ...
0
votes
1answer
222 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 ...
1
vote
3answers
604 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 ...
2
votes
1answer
465 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 ...
5
votes
2answers
698 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 ...
0
votes
1answer
760 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 ...
2
votes
3answers
156 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?
-1
votes
2answers
87 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 ...
3
votes
4answers
300 views

How unit testing helps QA testers?

I've faced this question in an interview..But I couldn't answer it well... Actually, I don't know the exact and professional answer for this one...Can anyone please help
0
votes
1answer
66 views

How to plan penetration testing in agile development?

Of course, as is well known, we plan of course Unit Test (in my case Junit) in the sprint, we have with QfS a GUI / Acceptance Test Framework which we plan accordingly in the sprint. The question but ...
4
votes
1answer
45 views

Design test class dependent on current datetime, 24 hours a day, seven days a week

I need to create a test to verify my NewBusinessDateTime.calculate(Integer hoursToAdd) works. The sudo code of what calculate() does is: IF currentDateTime.addHours(hoursToAdd) IS WITHIN BUSINESS ...
4
votes
1answer
75 views

Looking for examples of scenarios (types of code) which are ideal for unit testing

I was looking for some correct examples of when people did unit testing (specific scenarios of when unit testing was implemented) The term Unit Testing seems to frequently be used incorrectly. I am ...
1
vote
1answer
94 views

Importance of having tests in home test assignments when applying for a new job

I've been a part of the interviewing process for Software Engineering positions (including QA engineers as well) in our team for the past several years and I am still struggling to determine my ...
1
vote
0answers
35 views

Jasmine, how to test a return?

I'm writing some unit tests for our Angular application. In a few instances, we have some code that is like the following. public submit(): void { if (!this.selectedValue) { ...
4
votes
1answer
54 views

Use tested class during test setup and assertion? (Errors cancel out each other…)

This is a general question that affects lots of my unit tests as I just recognized: Can I use the class I'm unit testing to perform setups in my test cases? Here's a simplified version of the ...
0
votes
1answer
97 views

Creating a real file in a unit test?

I'm responsible strictly for documenting and unit-testing a Golang project. In the part of the SUT I'm currently on, a real file, identified by a file path, is being checked for its "Last modified by" ...
1
vote
0answers
70 views

Consumer-driven Contract Testing

I've just come across the term consumer-driven contract testing and, working as a QA, was wondering a few things: What does this actually mean in laymans terms? Who would generally execute this type ...
0
votes
1answer
54 views

How to solve the unit tester's dilemma

I'm working on testing an API server SDK written in Golang. My literal job on this is solely unit-testing, documenting the code under test, and of course reporting any fails with the rest of the dev ...
0
votes
1answer
493 views

Running test suite from both terminal using pytest and unittest runner but show only unittest runner results and execute once

i am trying to execute my following test suite: import unittest from Login_Page import LoginPageAndLogout def test_suite(): # get all tests from classes login_test = unittest.TestLoader()....
10
votes
5answers
158 views

How to handle “fake” unit tests that don’t really test anything?

I’m a part of a large software project which is supposed to use TDD. There are maybe 90 devs across the world. Upon review of tests for software components, I determined that a significant number of ...
5
votes
1answer
100 views

How to test code, that depends on file system errors?

I am developing a lib for a Linux project that stores files using boost::serialization. Because the files might be very large (1-50 GiB) and the program might fail writing them at some point (we are ...
2
votes
1answer
406 views

How to properly mock dependencies

My code is organized as several independent classes. Each dependency is injected by a setter, so in the end I create instances of classes B and C, set their parameters and inject them to class A. Now ...
14
votes
4answers
2k views

Test strategy to bring automated tests from UI to lower(API/Unit) layers?

Background/Problem Statement: Recently I came across a project team, which is having thousands of UI automated tests covering all kind of manual tests including positive, negative etc., and obviously ...
0
votes
1answer
96 views

Unit testing for chains of generators in Python

I want to write unit tests for methods that take a generator as input and produce a generator. I am building on this answer. For this question let's take the method: def candidates_for_deletion(self,...

1
2 3 4 5