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.

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.

Unit tests are created by programmers or occasionally by white box testers during the development process.

@ wikipedia

236 questions
18
votes
5 answers

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(String userID, String locationName) { …
Stu Whyte
  • 283
  • 1
  • 2
  • 7
15
votes
5 answers

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 testing could help? I see it as a waste of time.
Ryan
  • 153
  • 4
11
votes
4 answers

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 of the steps when I write the final draft. In…
AwayFromMyDesk
  • 123
  • 2
  • 6
7
votes
5 answers

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 think that they have done everything right,…
Kosh
  • 315
  • 1
  • 6
6
votes
3 answers

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 thorough investigation (click the link for full…
Tony
  • 61
  • 1
  • 2
6
votes
5 answers

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 for them is to have them write tests to learn the…
corsiKa
  • 7,092
  • 7
  • 39
  • 53
5
votes
2 answers

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 test my code? I'd like to cover all of my cases, but…
Moshe
  • 153
  • 4
5
votes
1 answer

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 piece of software is responsible for providing…
rockfort
  • 53
  • 3
5
votes
2 answers

Unit testing - what is a good way to do these quickly?

Unit testing currently takes up more than half my development time, and I'd like to streamline the process, are there any general tips or tricks that will help me write unit tests faster? I'm currently in the process of creating factories that…
tuskiomi
  • 153
  • 4
5
votes
4 answers

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 = Convert.ToInt16(textBoxValue1.Text); int value2…
sooprise
  • 633
  • 6
  • 9
4
votes
1 answer

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 following the definition of unit testing given by…
Fractal
  • 149
  • 7
4
votes
8 answers

How do testers perform unit testing?

I myself have no idea of how to code, so am I able to perform unit testing? Want answer in detail because I want to know how testers do unit testing.
Saddam Khan
  • 93
  • 2
  • 6
4
votes
1 answer

Unit Testing The Presenter (in an MVP Context) Using Mock Objects?

Below is some code which is just the simplest MVP project I could make. How can I unit test the presenter using mock objects? Does a mock object mean a completely made up object? In this case, the presenter needs an instance of Form1, and Form1…
sooprise
  • 633
  • 6
  • 9
3
votes
1 answer

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, negation of conditions, and so on. If such…
PiotrK
  • 133
  • 3
3
votes
2 answers

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 sense to apply to unit tests and which make sense…
Michael Durrant
  • 25,210
  • 3
  • 40
  • 112
1
2 3