Should unit tests cover stress testing?
NickName:dineth Ask DateTime:2010-08-09T14:01:56

Should unit tests cover stress testing?

I am wondering if you guys have any good reading to consider what to classify as unit testing / acceptance / integration testing. I have the following scenario and we're having a bit of a debate at work if it should be in unit tests:

In our data access layer, some statements use sql such as "select * from people where id IN ('x', 'y'), where the IN statement is dynamically generated according to the input. Recently we found out that our Oracle db have a limit of 1000 variables within the IN statement.

I personally think this is not a unit testing scenario. We test if the sql work against the database in unit tests and if the logic is right. However, stress testing should be done at higher level.

If we are to do testing with 1000s of records in unit tests, we need to fill the database each time with large number of records, which might be inefficient.

Any advice?

Copyright Notice:Content Author:「dineth」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/3437655/should-unit-tests-cover-stress-testing

Answers
gizmo 2010-08-09T06:14:24

Regarding your particuliar example, you should in fact consider to do 2 tests for it:\n\n\nThe first one is a Unit Test, and will check that your function can accept the maximum number of input requested by the requirements. If nothing is specified there, ask for clarification to the analyst. Dynamically generated requests such as this are a pain to debug afterward.\nThe second one is a Stress test. But it should not be performed onthis particular part of your code, but rather on the integrated part tha will use it. If you start stress testing unit block, you'll end up doing premature optimisation because you'll loose the big picture and start making assumptions on how this will work togetheter rather than observing how it does really.\n",


DixonD 2010-08-09T06:12:58

I believe that stress tests should be implemented as part of unit testing. Generally your unit tests should contain\n\n\nAccuracy tests\nFailure tests\nStress tests\n\n\nIf you don't want to run stress tests each time when you running other tests, you can consider to group stress tests in separate text fixture.",


More about “Should unit tests cover stress testing?” related questions

Should unit tests cover stress testing?

I am wondering if you guys have any good reading to consider what to classify as unit testing / acceptance / integration testing. I have the following scenario and we're having a bit of a debate at...

Show Detail

Unit Testing php application (What should I stress test?)

I am currently writing the unit tests for a php data access object. Obviously I should stress test the server environment at or above expected traffic levels, but as was answered to this question: ...

Show Detail

Should unit tests cover constants changing?

I am creating a unit test for my presenter. I have 2 constants for a ranges which definitely can be in future changed to a requests from server. So I wrote all my code in the way that it will work ...

Show Detail

Should you write unit tests for code that tests application behavior?

I'm wondering if you should or should not write unit tests for code that's part of the main application and can be called by the customer even though the code is only responsible for stress testing...

Show Detail

Should I cover the code by unit tests even it already has been covered by integration tests?

let's say we have some web service with REST API and for illustration there is some work with database. In my opinion, the most fundamental way to test this application are integration tests which ...

Show Detail

Are unit tests and acceptance tests enough?

If I have unit tests for each class and/or member function and acceptance tests for every user story do I have enough tests to ensure the project functions as expected? For instance if I have unit...

Show Detail

Why in unit testing tests should not depend on the order of execution?

It is a very often opinion that unit testing should not rely on tests order. I think it is not an exact rule but recommendation. But in some cases it does not look good. For example I have CUtility

Show Detail

Performance / Stress Testing Java EE applications

It's difficult to find all bottlenecks, deadlocks, and memory leaks in a Java application using unit tests alone. I'd like to add some level of stress testing for my application. I want to test the

Show Detail

Designing a Stress Testing Framework

I do a sort of integration/stress test on a very large product (think operating-system size), and recently my team and I have been discussing ways to better organize our test workloads. Up until no...

Show Detail

Stress-testing using Cucumber

I'm currently writing integration tests for a RoR REST API using cucumber. I'd also like to stress-test the API and was wondering how I might be able to re-use my cucumber scenarios to do this. ...

Show Detail