Example: tourism industry

Unit Testing in BlueJ

unit Testing in BlueJVersion BlueJ Version K llingM rsk InstituteUniversity of Southern DenmarkCopyright M. K llingUnit Testing in BlueJCopyright M. K lling unit Testing TEST TEST TEST IS A FIXTURE?..128 CREATING AND USING TEST TEST METHODS BY TESTS THE Testing in BlueJCopyright M. K lling 31 IntroductionSummary: BlueJ provides regression Testing functionality by integrating About this tutorial scope and audienceThis tutorial introduces the unit Testing functionality in the BlueJ environment.

This tutorial discusses BlueJ’s tools for systematic unit testing. If you are familiar with BlueJ’s interaction features, then you know that it is easy in BlueJ to test individual methods interactively. We refer to this as ad-hoc testing. Ad-hoc testing is useful, but not good enough for systematic testing. The unit testing

Tags:

  Testing, Unit, Tutorials, Bluej, Unit testing in bluej

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of Unit Testing in BlueJ

1 unit Testing in BlueJVersion BlueJ Version K llingM rsk InstituteUniversity of Southern DenmarkCopyright M. K llingUnit Testing in BlueJCopyright M. K lling unit Testing TEST TEST TEST IS A FIXTURE?..128 CREATING AND USING TEST TEST METHODS BY TESTS THE Testing in BlueJCopyright M. K lling 31 IntroductionSummary: BlueJ provides regression Testing functionality by integrating About this tutorial scope and audienceThis tutorial introduces the unit Testing functionality in the BlueJ environment.

2 Weassume that you are already familiar with BlueJ s general functionality. If not, read TheBlueJ Tutorial first. (You can get that tutorial, and an electronic version of this one, ).We also assume that you are somewhat familiar with the idea of unit Testing (or at leastsoftware Testing in general). We give a few pointers in the next What is unit Testing ?The term unit Testing refers to the individual Testing of separate units of a softwaresystem. In object-oriented systems, these units typically are classes and methods.

3 Thus,in our context, unit Testing refers to the individual Testing of methods and classes tutorial discusses BlueJ s tools for systematic unit Testing . If you are familiar withBlueJ s interaction features, then you know that it is easy in BlueJ to test individualmethods interactively. We refer to this as ad-hoc Testing is useful, but not good enough for systematic Testing . The unit testingfeatures in BlueJ give you the tools to record and replay tests, so that unit tests caneasily be repeated later (typically after a change in the system), so that the developer cangain some confidence that recent changes have not broken existing functionality.

4 This isknown as regression concepts of unit Testing and regression Testing are old, but their popularity wasgreatly increased recently with the publication of the eXtreme programmingmethodology1 and a unit Testing tool for Java, is a regression Testing framework written by Erich Gamma and Kent Beck. Youcan find the software and a lot of information about it at . 1 To find out what eXtreme programming is, have a look, for example, at Extreme ProgrammingExplained: Embrace Change , Kent Beck, Addison Wesley, 1999.

5 There are many other booksavailable. A good online summary is at Testing in BlueJCopyright M. K lling unit Testing in BlueJThe systematic Testing tools in BlueJ are based on JUnit. Thus, some knowledge aboutusing JUnit helps in understanding unit Testing in BlueJ . We recommend reading anarticle about this (maybe not right now, but some time later). Many such articles exist,and the JUnit web site is a good starting point to find Testing in BlueJ combines BlueJ s interactive Testing functionality with theregression Testing of JUnit.

6 Both Testing methods are fully supported. Additionally, newfunctionality resulting from the combination of the two systems is available: interactivetest sequences can be recorded, for example, to automatically create JUnit test methodsfor later regression Testing . Examples are given later in this unit Testing functionality in BlueJ was designed and implemented by AndrewPatterson (Monash University) as part of his PhD Testing in BlueJCopyright M. K lling 52 Enabling unit Testing functionalitySummary: Testing tools can be made visible with a switch in the explicit Testing support in BlueJ is initially disabled.

7 To use the Testing tools selectTools and select the checkbox labelled Show Testing this functionality adds three elements to the interface: some buttons and a recording indicator in the main window s tool bar, a Show Test Results item in theView menu, and a Create Test Class item in the popup menu of compiled Testing in BlueJCopyright M. K lling 63 Creating test classesSummary: Create a test class by selecting Create Test Class from the class popup first step to setting up Testing of a class or method in BlueJ is to create a test test class is a class associated with a project class (which we will call the referenceclass).

8 The test class contains tests for methods for the reference the examples in this tutorial, we use the people project, which is distributed withBlueJ as one of the examples in the examples directory. You may like to open it on yoursystem to try out things as you read can create a test class by right-clicking (MacOS: control-clicking) a compiled classand selecting the Create Test Class item from the popup menu. The test class isautomatically named by adding a Test suffix to the name of the reference class.

9 Forexample, if the reference class name is Student , the test class will be named StudentTest .Test classes are shown in the diagram marked with a << unit test>> tag attached to thereference class. They also have a different colour (Figure 1). Dragging the referenceclass will keep the test class 1: A reference class with an associated test classTest classes are treated in a specialised way by the environment. They have the usualclass functions (such as Open Editor, Compile, Remove), but also some test specificfunctions (Figure 2).

10 The test class must be compiled to see this Testing in BlueJCopyright M. K lling 7 Figure 2: The popup menu of a test classCreating the test class in itself does not create any tests, but it gives us the option ofcreating tests now. The test class is used to hold the test we will Testing in BlueJCopyright M. K lling 84 Creating test methodsSummary: Create a test method by selecting Create Test from the test class' objects have two methods, setName and getName (inherited from Person), toset and retrieve the name of the student.


Related search queries