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
0
votes
1answer
27 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
71 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 ...
3
votes
1answer
61 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
47 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
34 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
77 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
42 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
485 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
40 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
144 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
114 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 ...
1
vote
3answers
85 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
50 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
180 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
49 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
44 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
60 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
80 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
30 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
52 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
35 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
42 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: 1) what does this actually mean in laymans terms? 2) who would generally execute ...
0
votes
1answer
51 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
143 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
131 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
91 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
221 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 ...
13
votes
3answers
1k 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
47 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,...
5
votes
4answers
112 views

How to write unit test for methods with a large number of parameters?

I am asking in case I run into this scenario in the future. Someone in my company wrote multiple methods with 25 parameters. I don't know how/why it got thru code review. I'm just wondering how ...
3
votes
2answers
47 views

Should unit tests tests the same variety of sad cases as UAT tests?`

With UAT IT tests I frequently have some or all of the following types of tests: smoke (the page get at the endpoint loads), happy, sad, optional and audit. How many of these test types does it make ...
3
votes
2answers
311 views

Postman vs writing tests programmatically using curl or related vs unit tests

I am new to Rest API testing and this questions might be asked already. We are building a Rest API for our react applications using Laravel Framework (PHP). We want to test it but we are confused ...
0
votes
1answer
95 views

Test Impact Analysis tool for Python

Is there a Test Impact Analysis (TIA) framework/tool/extension for Python? E.g. an equivalent to JAVAs Test Impact Analysis Plugin for jQAssistant?
6
votes
6answers
110 views

mathematical/statistical relationship between tests and bugs?

As project manager, I would like to convince higher management to invest more time for development of unit tests for existing methods. My understanding is that unit testing is foundation/pre-req for ...
2
votes
1answer
264 views

Automated test generator

After a long road with Randoop.NET as a unit test suggestion tool, my developing team has decided to upgrade to a commercial tool which will provide us a full unit testing framework for professional ...
1
vote
4answers
57 views

How do you initially script/debug the long automated end to end UI tests?

Background: In the long end to end UI automated tests, one needs to execute multiple times during initial scripting/debugging and later for maintenance/fixing which takes a lot of time as a test might ...
2
votes
4answers
312 views

Why do unit testing if it doesn't find many bugs?

I was wondering if unit testing is effective in finding bugs or if that is not one of its major goals at all. We wrote unit tests for many business rules over time and after a few months we did not ...
2
votes
1answer
64 views

How to create unit tests for Web app with a database

I'm currently adding unit testing to my project and came across this question, How can I test my database insertion. For example, let's say I have a user table, I want to test if I can create a user, ...
1
vote
2answers
445 views

Advantage of python unit test in selenium

Hi I started building up automation suite using selenium with python. As most tutorial used python unit test framework. I have 5 scenarios of testing login page. Next 50 or more test are going to be ...
2
votes
1answer
589 views

Running python selenium test as suite

I have a simple test suite defined as below from unittest import TestLoader, TestSuite, TextTestRunner from TestScripts.LogOn import test_1 from TestScripts.FirstLog import test_2 if __name__ == "...
4
votes
1answer
94 views

Determine most depended-on code

Another title might be: determine strongest candidates for 100% test coverage. I'm looking for a tool that will display the methods/functions that are most depended on by my code base. To be clear, I'...
-1
votes
1answer
94 views

How to do unit test of 16 digit Generated Random number [closed]

Here i'm facing one problem that i have to do unit testing of 16 Digits of Generated Random( 9872 5432 8765 0987, 9852 7412 6587 2365.........n) number so these Random Number are generated from Sql ...
2
votes
2answers
437 views

How to perform “front end unit testing” of Single Page Applications?

"Front-end Unit Testing": To test the client side validations from front-end UI tests but in isolation(hence calling unit tests). By isolation mean, testing static HTML pages to avoid unnecessary ...
1
vote
1answer
1k views

How to fail NUnit test by default (I want to call Assert.Pass when it should pass)

I have medium level experience on unit testing and now I'm learning about NUnit. As far as I can see, a NUnit test passes by default if you don't call Assert.Fail method. In my test case, I want it ...
2
votes
1answer
37 views

Split roles for devs doing feature implementation and integration testing?

I'm looking out for patterns how to more effectively bring QA topics into our agile product development team. One idea is to let one developer do the implementation with TDD (so alongside unit tests) ...
0
votes
1answer
40 views

Step based unit testing

I've just joined a startup and would like to add some automated testing for some basic processes. I'd like something that's step based, i.e. run a step, test the output in some arbitrary way, and then ...
0
votes
1answer
269 views

Automation Testing the python code for Autonomous Driving Environment?

I am newbie to testing world. I am currently working on automation testing for a python code in the environment of Autonomous Car Company, is Robot Framework suitable for that? else which is the best ...
0
votes
2answers
51 views

How to schedule to run all unit tests?

I need to manage executing all unit tests on build server. Is there any idea about when is proper to run all of the unit tests on the build server. There are too many of them, and it will take hours ...
3
votes
3answers
497 views

Naming a positive “happy path” test case

We have a rather reach set of unit tests for our Python/Django backend. Most of the tests contain a one or more "happy" path tests and a lot of "negative" test cases checking the validation, error-...
3
votes
2answers
107 views

Testing internal dependencies - inject a mock of itself, or refactor into new class?

I've been given the task of refactoring some legacy code, the main reason is to add unit tests (but I'm a firm believer that testable code is better code, so we're trying to reduce technical debt too)....