词条 | Random testing |
释义 |
Random testing is a black-box software testing technique where programs are tested by generating random, independent inputs. Results of the output are compared against software specifications to verify that the test output is pass or fail.[1] In case of absence of specifications the exceptions of the language are used which means if an exception arises during test execution then it means there is a fault in the program, it is also used as way to avoid biased testing. History of random testingRandom testing for hardware was first examined by Melvin Breuer in 1971 and initial effort to evaluate its effectiveness was done by Pratima and Vishwani Agrawal in 1975.[1] In software, Duran and Ntafos had examined random testing in 1984.[2] OverviewConsider the following C++ function: int myAbs(int x) { if (x>0) { return x; } else { return x; // bug: should be '-x' } } Now the random tests for this function could be {123, 36, -35, 48, 0}. Only the value '-35' triggers the bug. If there is no reference implementation to check the result, the bug still could go unnoticed. However, an assertion could be added to check the results, like: void testAbs(int n) { for (int i=0; i } The reference implementation is sometimes available, e.g. when implementing a simple algorithm in a much more complex way for better performance. For example, to test an implementation of the Schönhage–Strassen algorithm, the standard "*" operation on integers can be used: int getRandomInput() { } void testFastMultiplication(int n) { for (int i=0; i While this example is limited to simple types (for which a simple random generator can be used), tools targeting object-oriented languages typically explore the program to test and find generators (constructors or methods returning objects of that type) and call them using random inputs (either themselves generated the same way or generated using a pseudo-random generator if possible). Such approaches then maintain a pool of randomly generated objects and use a probability for either reusing a generated object or creating a new one.[4] On randomnessAccording to the seminal paper on random testing by D. Hamlet [..] the technical, mathematical meaning of "random testing" refers to an explicit lack of "system" in the choice of test data, so that there is no correlation among different tests.[3] Strengths and weaknesses{{Unreferenced section|date=August 2014}}Random testing is typically praised for the following strengths:
The following weaknesses are typically pointed out by detractors:
Types of random testingWith respect to the input
Guided vs. unguided
ImplementationsSome tools implementing random testing:
CritiqueRandom testing has only a specialized niche in practice, mostly because an effective oracle is seldom available, but also because of difficulties with the operational profile and with generation of pseudorandom input values.[3] A test oracle is an instrument for verifying whether the outcomes match the program specification or not. An operation profile is knowledge about usage patterns of the program and thus which parts are more important. For programming languages and platforms which have contracts (for example Eiffel. .NET or various extensions of Java like JML, CoFoJa...) contracts act as natural oracles and the approach has been applied successfully.[7] In particular, random testing finds more bugs than manual inspections or user reports (albeit different ones).[8] See also
References1. ^{{cite journal|url=http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=1672882&tag=1|title=Probabilistic Analysis of Random Test Generation Method for Irredundant Combinational Logic Networks|first1=P.|last1=Agrawal|first2=V. D.|last2=Agrawal|date=1 July 1975|journal=IEEE Transactions on Computers|volume=C-24|issue=7|pages=691–695|accessdate=15 November 2017|via=IEEE Xplore|doi=10.1109/T-C.1975.224289}} 2. ^{{cite journal|url=http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=5010257|title=An Evaluation of Random Testing|first1=J. W.|last1=Duran|first2=S. C.|last2=Ntafos|date=1 July 1984|journal=IEEE Transactions on Software Engineering|volume=SE-10|issue=4|pages=438–444|accessdate=15 November 2017|via=IEEE Xplore|doi=10.1109/TSE.1984.5010257}} 3. ^1 2 {{cite book|title=Encyclopedia of Software Engineering|year=1994|publisher=John Wiley and Sons|isbn=978-0471540021|author=Richard Hamlet|edition=1st|editor=John J. Marciniak|chapter=Random Testing}} 4. ^1 {{cite web|url=http://stackoverflow.com/questions/636353/is-it-a-bad-practice-to-randomly-generate-test-data|title=Is it a bad practice to randomly-generate test data?|website=stackoverflow.com|accessdate=15 November 2017}} 5. ^{{cite journal|last=Pacheco|first=Carlos|author2=Shuvendu K. Lahiri |author3=Michael D. Ernst |author4=Thomas Ball |title=Feedback-directed random test generation|journal=ICSE '07: Proceedings of the 29th International Conference on Software Engineering|date=May 2007|pages=75–84|url=http://people.csail.mit.edu/cpacheco/publications/feedback-random.pdf|issn=0270-5257}} 6. ^{{cite journal|last=Chen|first=T.Y.|author2=H. Leung |author3=I.K. Mak | title=Adaptive Random Testing |journal=Advances in Computer Science - ASIAN 2004. Higher-Level Decision Making |date= 2005|pages=320–329|url=http://www.utdallas.edu/~ewong/SYSM-6310/03-Lecture/02-ART-paper-01.pdf}} 7. ^1 2 {{cite web|url=http://se.inf.ethz.ch/research/autotest/|title=AutoTest - Chair of Software Engineering|website=se.inf.ethz.ch|accessdate=15 November 2017}} 8. ^{{cite journal|title=On the number and nature of faults found by random testing|year=2009|author=Ilinca Ciupa|author2=Alexander Pretschner|author3=Manuel Oriol|author4=Andreas Leitner|author5=Bertrand Meyer|journal=Software Testing, Verification and Reliability|doi=10.1002/stvr.415|volume=21|pages=3–28}} External links
1 : Software testing |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。