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
31 votes
4 answers
2k views

Developing Unit Tests While Refactoring Legacy Code?

I have a big code library that I need to refactor in order for it to fit more nicely together (one big problem is there aren't clear enough boundaries between each component). Since there will be ...
user avatar
  • 623
30 votes
9 answers
4k views

With good unit tests, do I also need acceptance tests?

Given I have written good unit tests for business rule units of a system. Is it still needed to write acceptance tests that target verifying those business rules implementation?
user avatar
24 votes
3 answers
3k views

What's the recommended practice for separating unit tests from integration tests for automated testing?

On a project I've been working on, we've been steadily increasing the code coverage through tests. Some of these tests were done as integration tests and some as unit tests. The integration tests can ...
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
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 ...
user avatar
  • 535
18 votes
5 answers
11k views

Should I unit test for null values even if it can never happen?

Lets say I have an event listener that is called whenever a person has changed their location. Here's some Java code. public class LocationManager() { //.. .. ..// public void updateLocationFromGPS(...
user avatar
  • 283
16 votes
5 answers
365 views

If I didn't use TDD but want to transition to agile, should I go back and create those unit tests?

In an transitioning agile environment, if there was no Test Driven Development (no unit tests created), should you create unit tests to catch up on technical debt? and to what extent? Should ...
user avatar
  • 535
16 votes
4 answers
5k views

Documenting Unit Tests

We follow a BDD approach to development, we have our testers creating scenarios from a specification, and these are then given to our developers before any work is started. However, we find that some ...
user avatar
  • 2,930
15 votes
5 answers
2k views

Should I unit test small projects?

I develop small projects, and the testing is usually a functional test when I verify if the service is working as I were the user. Is this ok with small projects of 2-3 people? How do you think unit ...
user avatar
  • 153
15 votes
4 answers
3k 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 ...
user avatar
13 votes
2 answers
3k views

How to avoid redundant tests

We are building an application using a completely test-driven approach. As developers, we are very familiar with unit tests but haven't been exposed to integrated / functional / acceptance tests. ...
user avatar
  • 233
11 votes
4 answers
6k views

Writing test cases before implementation?

So currently at my company it is common practice to write test case high level steps before implementation. Myself and others find this to be a somewhat wasted effort. I often end up blowing away much ...
user avatar
11 votes
6 answers
775 views

How can testers motivate developers to write unit tests?

Unit-testing, oftentimes, is thought of as a burden and not exciting at all - more code to write, configure and maintain which requires time which results into delays in delivering features or fixes. ...
user avatar
  • 11.4k
11 votes
2 answers
2k views

Implementing the Test Pyramid as QA

Recently I have begun building out Unit Testing for my dev team during down time in an attempt to implement the Test Pyramid. My Dev Managers seem rather excited about it and on-board with the idea. ...
user avatar
  • 3,212
10 votes
3 answers
3k views

What is really tested in an integration test?

what is really the difference between a component/unit test and an integration test? Suppose you do very fine unit testing with stubs and drivers and test each component as far as you can with unit ...
user avatar
  • 101
10 votes
2 answers
701 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
10 votes
5 answers
216 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 ...
user avatar
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 ...
user avatar
  • 193
9 votes
2 answers
5k views

NUnit: Global error method/event for handling exceptions

I'm looking for a way to catch exceptions globally in my NUnit project class library. So if one of my unit tests throws an exception, I can catch it in one spot. I don't want to surround each of my ...
user avatar
  • 1,223
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'...
user avatar
  • 99
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 ...
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
7 votes
4 answers
10k views

Is there any framework for UI automation testing for Unity3D?

Does anyone know any framework that is compatible/integrated with Unity3D? I'm interested in Unit, Integrated and UI testing.
user avatar
  • 71
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 ...
user avatar
  • 71
7 votes
2 answers
165 views

Are there some well known pitfalls to avoid when starting with unit testing on a "legacy" web application?

I am participating on the development of the web application which has several years of history behind it and there never was enough value and effort put on refactoring, so considerable part of the ...
user avatar
7 votes
3 answers
482 views

What kind of testing is ApprovalTests.com doing and are there other similar frameworks?

I came across the ApprovalTests.com framework today and am curious how it would be classified. I am familiar with concepts of Unit Tests, functional tests, and user acceptance testing, but this seems ...
user avatar
  • 173
7 votes
2 answers
416 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
7 votes
1 answer
1k views

What are the tiers of testing that should be done on a large scale distributed system?

Let's say you have a large distributed system in the cloud that's got dozens of developers working on it and actively adding code to. Your job is to make sure all of the quality gates are used and the ...
user avatar
  • 173
6 votes
4 answers
435 views

Where to focus testing? On integration level or unit level?

Consider a modern web application that serves JSON through a REST API to a rich Javascript-based application with one or more single-page apps within it. Our own application is written using Angular ...
user avatar
  • 163
6 votes
1 answer
439 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
  • 61
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 ...
user avatar
5 votes
5 answers
454 views

Writing tests to learn the code

My team is bringing on two new people - an intern and a full time. The intern has one semester to go, and the full time is fresh out of uni. After a two week training period, the plan management has ...
user avatar
  • 7,042
5 votes
3 answers
130 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
5 votes
4 answers
394 views

System integration testing

I had some questions around system/integration test. We have a development team and a full QA team, which does customer focused testing for our product. We want to introduce a middle test team which ...
user avatar
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 ...
user avatar
  • 623
5 votes
2 answers
3k views

Pros and cons of python unit testing packages

I am starting on my first large scale python project and I want to put the right testing package in place not only to get the job done but also so when hiring people down the road it's easy to find ...
user avatar
  • 163
5 votes
3 answers
2k views

How do you test your unit-tests for false negatives?

How do you test your unit-tests for false negatives (tests that pass but should have failed). For example, I am writing a mission-critical class in JavaScript. To make sure every little nook and ...
user avatar
5 votes
3 answers
161 views

Is this a good simplification of fake object types?

With every unit testing text I get my hands on comes a little different terminology and more or less different definitions of various fake object types. I find that a lot of this differentiation is ...
user avatar
5 votes
2 answers
2k views

Getting warning from unit test

I get a warning from this test but I don't know how to handle it. The warning is /usr/lib/python3.5/unittest/case.py:600: ResourceWarning: unclosed file <_io.BufferedReader name='/tmp/...
user avatar
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 ...
user avatar
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
5 votes
1 answer
11k views

Try Assert Exceptions not failing test in python unittest or better way to loop through failures

Okay I am running Chromedriver test that gathers console logs and then tests an assertion against pythons unittest. class ConsoleLogsTest(unittest.TestCase): @classmethod def setUpClass(cls)...
user avatar
  • 235
5 votes
2 answers
259 views

How do I reasonably unit test calendrical calculations?

I've written some code that performs some action, depending on the day of the year and the year. There are an infinite number of years, hence an infinite number of days? What's a good way to unit ...
user avatar
  • 153
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 ...
user avatar
  • 5,834
5 votes
2 answers
904 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
5 votes
1 answer
85 views

How to unit test the plethora of js frameworks?

There's a bunch of popular javascript frameworks such as Angular React Vue Ember Meteor What tools exist for unit (white box) testing each of them? Does each framework support its own unit testing ...
user avatar
5 votes
1 answer
2k views

xcodebuild does not run any unit tests when launched from console

My first question here so please bear with me. It may be off topic, if so - close the question. I have setup Jenkins with git and Xcode plugins so that I would be able to build an iOS project on CI ...
user avatar
  • 183
5 votes
2 answers
571 views

Differences between Standard for Software Component Testing (BCS, SIGIST, 2001) and BS 7925-2:1998

What (if any) are the differences between The Standard for Software Component Testing (from the British Computing Society SIGIST and available for free) and BS 7925-2 (which is available to purchase ...
user avatar
  • 151
5 votes
1 answer
108 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 ...
user avatar
  • 153
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 ...
user avatar
  • 51

1
2 3 4 5