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
28
votes
9answers
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?
28
votes
4answers
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 ...
21
votes
3answers
2k 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 ...
19
votes
7answers
1k 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 practicing Scrum. Being the QA lead, really the only tester on a small team, how can I get the process more aligned with ...
17
votes
5answers
6k 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(...
15
votes
4answers
321 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 ...
15
votes
5answers
1k 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 ...
15
votes
4answers
3k 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 ...
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 ...
13
votes
2answers
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. ...
11
votes
4answers
5k 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 ...
11
votes
6answers
426 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. ...
10
votes
5answers
130 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 ...
9
votes
4answers
2k 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 ...
8
votes
2answers
1k 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. ...
8
votes
2answers
4k 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 ...
8
votes
6answers
904 views

Database code unit testing tips

I am working on developing a big 3-tier application. Database has a lot of code (stored procedures, functions, triggers...). I am looking for a valid approaches how to implement unit testing for the ...
7
votes
3answers
12k views

What are the test cases or test scenarios for palindrome

In the interview, the employer asked me to write test cases or test scenarios to check the Palindrome of the word. I said one with positive test case and another with negative test cases. But employer ...
7
votes
4answers
8k 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.
7
votes
3answers
566 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'...
7
votes
1answer
922 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 ...
6
votes
2answers
143 views

Are there some well known nasty pitfalls to try to avoid at all costs 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 ...
6
votes
6answers
109 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 ...
5
votes
4answers
371 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 ...
5
votes
5answers
412 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 ...
5
votes
4answers
330 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 ...
5
votes
4answers
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 value1 = ...
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 ...
5
votes
3answers
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 ...
5
votes
3answers
135 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 ...
5
votes
2answers
2k 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 ...
5
votes
1answer
172 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 ...
5
votes
1answer
7k 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)...
5
votes
3answers
299 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 ...
5
votes
2answers
252 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 ...
5
votes
2answers
127 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 ...
5
votes
1answer
57 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 ...
5
votes
1answer
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 ...
5
votes
2answers
494 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 ...
5
votes
1answer
89 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 ...
4
votes
4answers
273 views

How would I unit test these functions?

I have the following functions : Get(ds,filename) - gets a file from a data source ds. Put(ds,filename) - puts a file into a data source ds. List(ds) - lists all files in data source ds. Delete(ds,...
4
votes
2answers
546 views

Testing programs that handle huge datasets

I'm writing a script that parses many thousands of lines from a server log and collates the data. I'm wondering how to go about creating unit-tests for such a program, to make sure it gathers the data ...
4
votes
3answers
84 views

Test Case for Each Unit Test?

It seems highly impractical to have a test case/ticket for every unit test; however, the only experiences I have to draw from are from college, and an internship -both of which stressed having each ...
4
votes
3answers
217 views

How would you call on-device unit tests ?

In the embedded world some (unit) tests have minimal value when they run as standalone test, like unit tests should. We have many tests that run on the embedded device, as part of the embedded ...
4
votes
3answers
2k views

Creating a dummy database for automated functionality testing

I have a continuous integration build server (using Team City). When people check code in, I'd like to run a set of tests which run through a set of functional cases such as: Using an administrator ...
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 ...
4
votes
1answer
97 views

Automated Unit Testing

Imagine we have framework (any tool or language, BDD, Non-BDD) that both QA and Dev teams are using. Dev team would be writing and executing Unit Test cases and QA Team will be writing functional, ...
4
votes
3answers
153 views

Do I Need To Create Mock Classes For Every Class?

Let's say I have a system composed of three classes: A,B,C that share certain dependencies. To test A independently, I would need to create mock objects for B and C To test B independently, I would ...
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
57 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 ...