Common use of Unit testing object-oriented software Clause in Contracts

Unit testing object-oriented software. Unit testing in general represents the idea of automatically testing small pro- gram fragments, i.e., a unit or component, by executing a test program which incorporates the unit under test [62]. In the context of procedural or functional programming languages, a unit is often considered to be a procedure or, respec- tively, a function. Concerning object-oriented languages the smallest unit is used to mean an object or a class (depending on whether one wants to refer to dy- namical, or respectively, static aspects). To test a unit, a test program interacts with the unit and possibly investigates the resulting change of the program state. While in a procedural or functional language these interactions are usually car- ried out in terms of function or a procedure calls, an object-oriented test program investigates the unit by means of method calls. A central aspect of object-oriented programming, however, is that objects heavily rely on the interaction with other objects. Thus, most often, an object-oriented unit test program has to ensure the existence of several collaborator objects that are required to cooperate as assumed by the unit in order to enable the unit to fulfill its tasks. Due to this fact, it is generally accepted that, regarding object-oriented systems, unit testing coincides with integration testing or, at least, that the dividing line between the two testing activities is blurred (cf. [6] and [16], for instance). As a consequence, writing unit tests in an object-oriented setting is usually considerably more complex. However, a couple of testing frameworks exist that aim at unit testing object-oriented com- ponents. We will have a closer look at three of these frameworks. The first two frameworks are widely used, specifically by the extreme programming community. Despite its usefulness, the third framework is not so commonly accepted. All three frameworks aim at the Java programming language. However, similar approaches do exist also for C] and other related object-oriented programming languages. To allow for comparison, each framework is illustrated by a simple example, realizing the test of a voting system. The voting system is a component that, when activated by an initiator, collects a vote from a group of external voter objects, compiles a report, and returns it to the initiator. It can be used, for example, to detect termination of a group of objects.1 In our example, the voter system is implemented by means of a class Census defining a method conductVoting which realizes the above mentioned voting procedure. In particular, the method expects a list of Voter objects which, in turn, yield their vote in terms of a return value of a method vote. An exemplary implementation is sketched in Listing 1.1.

Appears in 2 contracts

Samples: scholarlypublications.universiteitleiden.nl, scholarlypublications.universiteitleiden.nl

AutoNDA by SimpleDocs

Unit testing object-oriented software. β€Œ Unit testing in general represents the idea of automatically testing small pro- gram fragments, i.e., a unit or component, by executing a test program which incorporates the unit under test [62]. In the context of procedural or functional programming languages, a unit is often considered to be a procedure or, respec- tively, a function. Concerning object-oriented languages the smallest unit is used to mean an object or a class (depending on whether one wants to refer to dy- namical, or respectively, static aspects). To test a unit, a test program interacts with the unit and possibly investigates the resulting change of the program state. While in a procedural or functional language these interactions are usually car- ried out in terms of function or a procedure calls, an object-oriented test program investigates the unit by means of method calls. A central aspect of object-oriented programming, however, is that objects heavily rely on the interaction with other objects. Thus, most often, an object-oriented unit test program has to ensure the existence of several collaborator objects that are required to cooperate as assumed by the unit in order to enable the unit to fulfill its tasks. Due to this fact, it is generally accepted that, regarding object-oriented systems, unit testing coincides with integration testing or, at least, that the dividing line between the two testing activities is blurred (cf. [6] and [16], for instance). As a consequence, writing unit tests in an object-oriented setting is usually considerably more complex. However, a couple of testing frameworks exist that aim at unit testing object-oriented com- ponents. We will have a closer look at three of these frameworks. The first two frameworks are widely used, specifically by the extreme programming community. Despite its usefulness, the third framework is not so commonly accepted. All three frameworks aim at the Java programming language. However, similar approaches do exist also for C] # and other related object-oriented programming languages. To allow for comparison, each framework is illustrated by a simple example, realizing the test of a voting system. The voting system is a component that, when activated by an initiator, collects a vote from a group of external voter objects, compiles a report, and returns it to the initiator. It can be used, for example, to detect termination of a group of objects.1 In our example, the voter system is implemented by means of a class Census defining a method conductVoting which realizes the above mentioned voting procedure. In particular, the method expects a list of Voter objects which, in turn, yield their vote in terms of a return value of a method vote. An exemplary implementation is sketched in Listing 1.1.

Appears in 1 contract

Samples: scholarlypublications.universiteitleiden.nl

AutoNDA by SimpleDocs

Unit testing object-oriented software. β€Œ Unit testing in general represents the idea of automatically testing small pro- gram fragments, i.e., a unit or component, by executing a test program which incorporates the unit under test [62]. In the context of procedural or functional programming languages, a unit is often considered to be a procedure or, respec- tively, a function. Concerning object-oriented languages the smallest unit is used to mean an object or a class (depending on whether one wants to refer to dy- namical, or respectively, static aspects). To test a unit, a test program interacts with the unit and possibly investigates the resulting change of the program state. While in a procedural or functional language these interactions are usually car- ried out in terms of function or a procedure calls, an object-oriented test program investigates the unit by means of method calls. A central aspect of object-oriented programming, however, is that objects heavily rely on the interaction with other objects. Thus, most often, an object-oriented unit test program has to ensure the existence of several collaborator objects that are required to cooperate as assumed by the unit in order to enable the unit to fulfill its tasks. Due to this fact, it is generally accepted that, regarding object-oriented systems, unit testing coincides with integration testing or, at least, that the dividing line between the two testing activities is blurred (cf. [6] and [16], for instance). As a consequence, writing unit tests in an object-oriented setting is usually considerably more complex. However, a couple of testing frameworks exist that aim at unit testing object-oriented com- ponents. We will have a closer look at three of these frameworks. The first two frameworks are widely used, specifically by the extreme programming community. Despite its usefulness, the third framework is not so commonly accepted. All three frameworks aim at the Java programming language. However, similar approaches do exist also for C] and other related object-oriented programming languages. To allow for comparison, each framework is illustrated by a simple example, realizing the test of a voting system. The voting system is a component that, when activated by an initiator, collects a vote from a group of external voter objects, compiles a report, and returns it to the initiator. It can be used, for example, to detect termination of a group of objects.1 In our example, the voter system is implemented by means of a class Census defining a method conductVoting which realizes the above mentioned voting procedure. In particular, the method expects a list of Voter objects which, in turn, yield their vote in terms of a return value of a method vote. An exemplary implementation is sketched in Listing 1.1.

Appears in 1 contract

Samples: scholarlypublications.universiteitleiden.nl

Time is Money Join Law Insider Premium to draft better contracts faster.