Questions tagged [testing]

Software testing is any activity aimed at evaluating an attribute or capability of a program or system and determining that it meets its required results.

For better answers, any questions about Software Quality Assurance & Testing should be asked on SQA - https://sqa.stackexchange.com/. You can ask only programming related questions on Stack Overflow and that too can be asked on SQA

From Wikipedia:

Software testing is an investigation conducted to provide developers and stakeholders with information about the quality of the product or service under test. Software testing can also provide an objective, independent view of the software to allow the business to appreciate and understand the risks of software implementation.

Test techniques include, but are not limited to, the process of executing a program or application with the intent of finding software bugs (errors or other defects).

Software testing can be stated as the process of validating and verifying that a software program/application/product:

  1. meets the requirements that guided its design and development;
  2. works as expected;
  3. can be implemented with the same characteristics.

There are white-box-tests and black-box-tests.

A white-box test verifies the structure of a software product whereas the block-box test validates the requirements.

Software testing, depending on the testing method employed, can be implemented at any time in the development process. However, most of the test effort occurs after the requirements have been defined and the coding process has been completed. As such, the methodology of the test is governed by the software development methodology adopted.

The following types of tests are commonly used to denote the level of detail the tests are focused on:

Agile and Test Driven Development

Agile development model places added emphasis on testing. Test driven development advocates writing a test for a feature before developing the actual feature. Additional information:

Shift-left testing

Shift-left testing is an approach to software testing and system testing in which testing is performed earlier in the lifecycle (i.e. moved left on the project timeline).

49776 questions
255
votes
20 answers

When should I use Debug.Assert()?

I've been a professional software engineer for about a year now, having graduated with a CS degree. I've known about assertions for a while in C++ and C, but had no idea they existed in C# and .NET at all until recently. Our production code contains…
245
votes
15 answers

Determine if a function exists in bash

Currently I'm doing some unit tests which are executed from bash. Unit tests are initialized, executed and cleaned up in a bash script. This script usualy contains an init(), execute() and cleanup() functions. But they are not mandatory. I'd like to…
terminus
  • 13,745
  • 8
  • 34
  • 37
244
votes
23 answers

Trying to mock datetime.date.today(), but not working

Can anyone tell me why this isn't working? >>> import mock >>> @mock.patch('datetime.date.today') ... def today(cls): ... return date(2010, 1, 1) ... >>> from datetime import date >>> date.today() datetime.date(2010, 12, 19) Perhaps someone could…
Belmin Fernandez
  • 8,307
  • 9
  • 51
  • 75
239
votes
9 answers

How can I time a code segment for testing performance with Pythons timeit?

I've a python script which works just as it should, but I need to write the execution time. I've googled that I should use timeit but I can't seem to get it to work. My Python script looks like this: import sys import getopt import timeit import…
Emil Devantie Brockdorff
  • 4,724
  • 12
  • 59
  • 76
236
votes
5 answers

Force retesting or disable test caching

Problem: When I run the same go test twice the second run is not done at all. The results are the cached ones from the first run. PASS ok tester/apitests (cached) Links I already checked https://golang.org/cmd/go/#hdr-Testing_flags but…
Simon Frey
  • 2,539
  • 2
  • 11
  • 20
233
votes
1 answer

Verify a method call using Moq

I am fairly new to unit testing in C# and learning to use Moq. Below is the class that I am trying to test. class MyClass { SomeClass someClass; public MyClass(SomeClass someClass) { this.someClass = someClass; } …
user591410
  • 3,051
  • 5
  • 21
  • 30
222
votes
20 answers

How do I simulate a low bandwidth, high latency environment?

I need to simulate a low bandwidth, high latency connection to a server in order to emulate the conditions of a VPN at a remote site. The bandwidth and latency should be tweakable so I can discover the best combination in order to run our software…
Nic
  • 4,319
  • 5
  • 29
  • 36
221
votes
9 answers

How do I disable a test using pytest?

Let's say I have a bunch of tests: def test_func_one(): ... def test_func_two(): ... def test_func_three(): ... Is there a decorator or something similar that I could add to the functions to prevent pytest from running just that test?…
ericmjl
  • 13,541
  • 12
  • 51
  • 80
221
votes
15 answers

Best way to compare 2 XML documents in Java

I'm trying to write an automated test of an application that basically translates a custom message format into an XML message and sends it out the other end. I've got a good set of input/output message pairs so all I need to do is send the input…
Mike Deck
  • 18,045
  • 16
  • 68
  • 92
220
votes
23 answers

How to check whether dynamically attached event listener exists or not?

Here is my problem: is it somehow possible to check for the existence of a dynamically attached event listener? Or how can I check the status of the "onclick" (?) property in the DOM? I have searched the internet just like Stack Overflow for a…
Stano
  • 8,749
  • 6
  • 30
  • 44
210
votes
20 answers

How to test code dependent on environment variables using JUnit?

I have a piece of Java code which uses an environment variable and the behaviour of the code depends on the value of this variable. I would like to test this code with different values of the environment variable. How can I do this in JUnit? I've…
vitaut
  • 49,672
  • 25
  • 199
  • 336
209
votes
9 answers

ReferenceError: describe is not defined NodeJs

I am trying to define some endpoints and do a test using nodejs. In server.js I have: var express = require('express'); var func1 = require('./func1.js'); var port = 8080; var server = express(); server.configure(function(){ …
N34
  • 2,153
  • 2
  • 11
  • 7
205
votes
10 answers

How do I get my Maven Integration tests to run

I have a maven2 multi-module project and in each of my child modules I have JUnit tests that are named Test.java and Integration.java for unit tests and integration tests respectively. When I execute: mvn test all of the JUnit tests *Test.java…
Peter Delaney
  • 5,278
  • 9
  • 33
  • 40
203
votes
5 answers

Sharing Test code in Maven

How can you depend on test code from another module in Maven? Example, I have 2 modules: Base Main I would like a test case in Main to extend a base test class in Base. Is this possible? Update: Found an acceptable answer, which involves…
flicken
  • 15,443
  • 4
  • 29
  • 29
201
votes
31 answers

Disadvantages of Test Driven Development?

What do I lose by adopting test driven design? List only negatives; do not list benefits written in a negative form.
IanL
  • 636
  • 4
  • 9
  • 23