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
145
votes
12 answers

django unit tests without a db

Is there a possibility to write django unittests without setting up a db? I want to test business logic which doesn't require the db to set up. And while it is fast to setup a db, I really don't need it in some situations.
paweloque
  • 18,466
  • 26
  • 80
  • 136
143
votes
9 answers

Simulate a button click in Jest

Simulating a button click seems like a very easy/standard operation. Yet, I can't get it to work in Jest.js tests. This is what I tried (and also doing it using jQuery), but it didn't seem to trigger anything: import { mount } from 'enzyme'; page =…
foobar
  • 3,849
  • 8
  • 22
  • 32
142
votes
8 answers

how to unit test asp.net core application with constructor dependency injection

I have a asp.net core application that uses dependency injection defined in the startup.cs class of the application: public void ConfigureServices(IServiceCollection services) { services.AddDbContext(options…
ganjan
  • 7,356
  • 24
  • 82
  • 133
141
votes
11 answers

How to test panics?

I'm currently pondering how to write tests that check if a given piece of code panicked? I know that Go uses recover to catch panics, but unlike say, Java code, you can't really specify what code should be skipped in case of a panic or what have…
ThePiachu
  • 8,695
  • 17
  • 65
  • 94
141
votes
6 answers

Junit: splitting integration test and Unit tests

I've inherited a load of Junit test, but these tests (apart from most not working) are a mixture of actual unit test and integration tests (requiring external systems, db etc). So I'm trying to think of a way to actually separate them out, so that I…
jeff porter
  • 6,560
  • 13
  • 65
  • 123
139
votes
18 answers

How to add test coverage to a private constructor?

This is the code: package com.XXX; public final class Foo { private Foo() { // intentionally empty } public static int bar() { return 1; } } This is the test: package com.XXX; public FooTest { @Test void…
yegor256
  • 102,010
  • 123
  • 446
  • 597
139
votes
7 answers

How to give System property to my test via Gradle and -D

I have a a Java program which reads a System property System.getProperty("cassandra.ip"); and I have a Gradle build file that I start with gradle test -Pcassandra.ip=192.168.33.13 or gradle test -Dcassandra.ip=192.168.33.13 however…
robkuz
  • 9,488
  • 5
  • 29
  • 50
138
votes
10 answers

How to set request headers in rspec request spec?

In the controller spec, I can set http accept header like this: request.accept = "application/json" but in the request spec, "request" object is nil. So how can I do it here? The reason I want to set http accept header to json is so I can do…
Sergey
  • 4,702
  • 6
  • 26
  • 32
138
votes
10 answers

How to mock functions in the same module using Jest?

What's the best way to correctly mock the following example? The problem is that after import time, foo keeps the reference to the original unmocked bar. module.js: export function bar () { return 'bar'; } export function foo () { return `I…
Mark
  • 12,359
  • 5
  • 21
  • 37
137
votes
6 answers

How to count members with jsonpath?

Is it possible to count the number of members using JsonPath? Using Spring MVC test I'm testing a controller that generates {"foo": "oof", "bar": "rab"} with: standaloneSetup(new FooController(fooService)).build() …
NA.
  • 6,451
  • 9
  • 36
  • 36
135
votes
6 answers

How do I programmatically shut down an instance of ExpressJS?

I'm trying to figure out how to shut down an instance of Express. Basically, I want the inverse of the .listen(port) call - how do I get an Express server to STOP listening, release the port, and shutdown cleanly? I know this seems like it might be…
drewww
  • 2,485
  • 4
  • 22
  • 24
135
votes
14 answers

How to check a checkbox in capybara?

I'm using Rspec and Capybara. How can I write a step to check a checkbox? I've tried check by value but it can't find my checkbox. I'm not sure what to do, as I have in fact same ID with different values Here is the code:
John Dow
  • 1,431
  • 2
  • 11
  • 8
135
votes
3 answers

When should you use render and shallow in Enzyme / React tests?

prior to posting this question, I tried to search in sqa stackexchange but I found no post about shallow and render there, so I hope someone can help me out here. When should I use shallow and render in testing react components? Based on the airbnb…
Cyval
  • 2,429
  • 4
  • 16
  • 27
135
votes
4 answers

How to turn off all SSL checks on Postman for a specific site?

Please read this carefully. Please do not send me a link on how to import a certificate. I am using Postman for QA and testing work. I have a test system I frequently rebuild myself and so it is completely trusted. It has a custom self-signed…
PJLopez
  • 1,459
  • 2
  • 9
  • 4
135
votes
18 answers

How to avoid "StaleElementReferenceException" in Selenium?

I am implementing a lot of Selenium tests using Java - sometimes, my tests fail due to a StaleElementReferenceException. Could you suggest some approaches to making the tests more stable?
hoang nguyen
  • 2,119
  • 5
  • 21
  • 20