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
5 votes
1 answer
313 views

Selenium tests aren´t launched anymore

I used to be able to launch all my Selenium2 WebDriver tests in Ruby on Rails via rake test:units. But recently, my test case(s) won't be found anymore. I don't get any notification or error message. ...
9 votes
3 answers
901 views

Exercises on software testing

I've been learning how to program in Python. I've passed the MIT course "Introduction to computer science, using Python" on edx.org. I can write small programs in Python. I want to become a tester. I'...
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 ...
0 votes
0 answers
10 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?
1 vote
1 answer
124 views

Mutation-testing generation [closed]

I'm giving a presentation about this paper: https://www.st.cs.uni-saarland.de/publications/files/fraser-tse-2011.pdf Unfortunately I don't understand 2 things: On page 9 table 1: Where are these ...
0 votes
0 answers
12 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 ...
9 votes
6 answers
940 views

Database code unit testing tips

I'm working on developing a big 3-tier application. Database has a lot of code (stored procedures, functions, triggers, etc). I'm looking for a valid approaches how to implement unit testing for the ...
0 votes
1 answer
697 views

Run the test JS and PHP in parallel via CircleCI

I use CircleCI to run JS and PHP test (Protractor/ Phpunit). I would like use parallelism to win time, but I don't know configure the parallelism. I activate the parallelism in the circle parameters (...
8 votes
3 answers
21k views

What are the test cases or test scenarios for palindrome?

In an interview, the interviewer asked me to write test cases or test scenarios to check if the input/string is a palindrome. I told them one positive test case and another negative test cases. But ...
3 votes
3 answers
576 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 ...
7 votes
7 answers
162 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 ...
1 vote
4 answers
96 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 ...
0 votes
0 answers
80 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 | +-...
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 ...
1 vote
1 answer
44 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 ...
0 votes
0 answers
95 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(...
1 vote
0 answers
39 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 ...
10 votes
2 answers
702 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. ...
3 votes
1 answer
77 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 ...
0 votes
1 answer
46 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 ...
1 vote
0 answers
109 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 ...
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 ...
0 votes
1 answer
89 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 ...
5 votes
5 answers
3k 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 ...
0 votes
1 answer
24 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 ...
1 vote
1 answer
65 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 ...
1 vote
1 answer
46 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 ...
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) { ...
2 votes
1 answer
913 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 ...
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 ...
1 vote
1 answer
60 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: ...
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) ...
5 votes
4 answers
3k views

UI and Business Logic Testing, Am I Doing it Right? Should I Unit Test Anything Else?

Alright, so this is what I have right now. buttonMultiply_Click(object sender, EventArgs e){ Calculator c = new Calculator(); textBoxLog.Text = "Calculation underway..."; int ...
0 votes
4 answers
20k views

How can I do data parameterization in Selenium Web Driver?

I want my test case to run once and test n number of inputs at various positions. Suppose If I want to check a login screen for different members like manager,user,admin,e.t.c then instead of running ...
20 votes
7 answers
2k views

In agile (Scrum) practices, where do I start with making QA (testing) more efficient if the team is transitioning from waterfall to agile?

My team has recently transitioned from the traditional waterfall method to practising Scrum. Being the QA lead, really the only tester on a small team, how can I get the process more aligned with ...
1 vote
1 answer
74 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
1 answer
110 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 ...
5 votes
3 answers
2k views

Asking for help with this Therac 25 bugged code. I don't understand the explanation

Therac 25 is a radiation therapy machine that lead to 3 deaths and 3 injuries in 1980s. That's the worst accidents in history which are caused by software bugs. In 1993, Leveson and Turner did a ...
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 ...
2 votes
6 answers
359 views

Will writing unit tests block developers from coding?

We are about to implement TDD in our software company and we met some serious questions. As you know, this is the TDD life cycle: Add a test Run all tests and see if the new test fails Write the ...
0 votes
0 answers
39 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. ...
4 votes
1 answer
124 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 ...
1 vote
1 answer
91 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 ...
1 vote
0 answers
80 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 ...
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 ...
4 votes
0 answers
1k views

Get Visual Studio (2013 Community) unit test execution messages

Hi, I'm trying to make a "nice" test execution report and get the following elements: Message StackTrace Elapsed time Test name and Test Outcome are easily taken as TestContext parameters, ...
5 votes
1 answer
110 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 ...
5 votes
1 answer
187 views

Are there common techniques for testing the conformance of an implementation to a general contract?

Say you have defined some abstract interface and you specify a general contract for that interface to which all implementations must adhere. Are there common techniques that can facilitate testing the ...
2 votes
2 answers
43 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?
4 votes
3 answers
212 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
2 3 4 5