Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performance Testing Versus Unit Testing

I'm reading Osherove's "The Art of Unit Testing," and though I've not yet seen him say anything about performance testing, two thoughts still cross my mind:

  • Performance tests generally can't be unit tests, because performance tests generally need to run for long periods of time.
  • Performance tests generally can't be unit tests, because performance issues too often manifest at an integration or system level (or at least the logic of a single unit test needed to re-create the performance of the integration environment would be too involved to be a unit test).

Particularly for the first reason stated above, I doubt it makes sense for performance tests to be handled by a unit testing framework (such as NUnit).

My question is: do my findings / leanings correspond with the thoughts of the community?

like image 329
Brent Arias Avatar asked May 20 '10 00:05

Brent Arias


People also ask

Can performance testing be done during unit testing?

Performance tests generally can't be unit tests, because performance issues too often manifest at an integration or system level (or at least the logic of a single unit test needed to re-create the performance of the integration environment would be too involved to be a unit test).

What is difference between performance testing and functional testing?

The main difference between performance testing and functional testing is the purpose. Performance testing checks whether the application remains functional under increased demand. Functional testing simply checks that the software works.

What is meant by performance testing?

What is performance testing? Performance testing is the practice of evaluating how a system performs in terms of responsiveness and stability under a particular workload. Performance tests are typically executed to examine speed, robustness, reliability, and application size.


3 Answers

I agree with your findings/learnings. True unit tests only test a portion of the system, ignoring, mocking or faking the rest as necessary. Integration tests (or regression tests) test most or all of the units working together, and that is the true measure of performance.

like image 189
Kaleb Brasee Avatar answered Nov 09 '22 23:11

Kaleb Brasee


In some situations you can use unit tests to make sure that an operation finishes within a certain time period. If you want to add more features to your operation, but you don't want to sacrifice performance you can use unit tests to assert that. Of course, these kind of unit tests are machine dependent, but you can throw some additional variables or configuration to the equation.

like image 42
serega Avatar answered Nov 09 '22 22:11

serega


Performance tests might very well be made up of unit tests.

For example, a unit test might throw several different parameters into a method and verify the method returns an expected output. A performance test might execute that unit test 1000 times (or whatever value makes sense for you) while recording everything from CPU and memory counters right down to how long each test took.

like image 42
NotMe Avatar answered Nov 09 '22 23:11

NotMe