Testing dan Implementasi Sistem materi 4 StateTransition Testing

  • Slides: 34
Download presentation
Testing dan Implementasi Sistem materi 4

Testing dan Implementasi Sistem materi 4

State-Transition Testing Example in Reservation system 2

State-Transition Testing Example in Reservation system 2

State-Transition Testing Example Ø State-Transition diagrams are an excellent tool to capture certain types

State-Transition Testing Example Ø State-Transition diagrams are an excellent tool to capture certain types of system requirements and to document internal system design. Ø These diagrams document the events that come into and are processed by a system as well as the system's responses. 3

Reservation system example 1 - Make a reservation Ø Provide information including departure and

Reservation system example 1 - Make a reservation Ø Provide information including departure and destination cities, dates, and times. Ø A reservation agent uses that information to make a reservation. Ø At that point, the Reservation is in the Made state. The system creates and starts a timer. Ø If this timer expires before the reservation is paid for, the reservation is cancelled by the system. 4

The Reservation is Made give. Info, is an event that comes into the system

The Reservation is Made give. Info, is an event that comes into the system from the outside world. The command after the "/" denotes an action of the system; in this case start. Pay. Timer. 5

2 - Pay for the Reservation - Pay. Money The Reservation transitions to the

2 - Pay for the Reservation - Pay. Money The Reservation transitions to the Paid state. Events may have parameters associated with them. For example, Pay Money may indicate Cash, Check, Debit Card, or Credit Card 6

3 - Print the ticket: - print The Reservation transitions to the Ticketed state.

3 - Print the ticket: - print The Reservation transitions to the Ticketed state. 7

4 - Give ticket Ø give. Ticket to the gate agent to board the

4 - Give ticket Ø give. Ticket to the gate agent to board the plane Ø The Reservation transitions to the Used state. 8

4 - Give ticket (Cont. ) The path ends 9

4 - Give ticket (Cont. ) The path ends 9

5 - Cancel for no payment by the ‘Pay. Timer’ Ø If the Reservation

5 - Cancel for no payment by the ‘Pay. Timer’ Ø If the Reservation is not paid the Pay. Timer expires and the Reservation is cancelled for non-payment. 10

6 - Cancel by customer Ø When the customer asks to cancel the Reservation

6 - Cancel by customer Ø When the customer asks to cancel the Reservation Cancel the Reservation from the Made state 11

7 - Cancel by customer after payment Ø A Reservation is cancelled from the

7 - Cancel by customer after payment Ø A Reservation is cancelled from the Paid state, a Refund should be generated and leave the system Ø Cancellation from the Paid state 12

8 - Customer cancels after receiving the ticket Ø From the Ticketed state, the

8 - Customer cancels after receiving the ticket Ø From the Ticketed state, the customer cancel the Reservation. Ø In that case a Refund should be generated. Ø The airline will generate a refund but only when it receives the printed Ticket from the customer. l Ø This introduces one new notational element—square brackets [. . ] that contain a conditional that can be evaluated either True or False. This conditional acts as a guard allowing the transition only if the condition is true. 13

8 - Customer cancels after receiving the ticket (cont. ) Cancellation from the Ticketed

8 - Customer cancels after receiving the ticket (cont. ) Cancellation from the Ticketed state 14

State-Transition Tables Creating Test Cases Ø State-transition tables may be easier to use in

State-Transition Tables Creating Test Cases Ø State-transition tables may be easier to use in a complete and systematic manner. Ø State-transition tables consist of four columns Current State, Event, Action, and Next State. 15

Creating Test Cases 1. Create a set of test cases such that all states

Creating Test Cases 1. Create a set of test cases such that all states are "visited" at least once under test. The set of three test cases shown below meets this requirement. Generally this is a weak level of test coverage. A set of test cases that "visit" each state 16

Create a set of test cases such that all transitions are exercised at least

Create a set of test cases such that all transitions are exercised at least once under test. 2. l l This level of testing provides a good level of coverage without generating large numbers of tests. This level is generally the one recommended. A set of test cases that trigger all transitions at least once 17

4. A set of test cases that trigger all transitions at least once (Cont.

4. A set of test cases that trigger all transitions at least once (Cont. ) Test cases can also be read directly from the state-transition table. Ø The gray rows in the following table show all the valid transitions. Ø 18

19

19

20

20

21

21

The End Session Any Problems? ? ?

The End Session Any Problems? ? ?

23

23

Kelas “Reservation” 24

Kelas “Reservation” 24

Kelas “Made” 25

Kelas “Made” 25

Kelas “Paid” 26

Kelas “Paid” 26

27

27

28

28

State-Transition Testing (Cont. ) Summary Ø State-Transition diagrams efforts by identifying the states, events,

State-Transition Testing (Cont. ) Summary Ø State-Transition diagrams efforts by identifying the states, events, actions, and transitions. These define how a system interacts with the outside world, the events it processes, and the valid and invalid order of these events. Ø The generally recommended level of testing using statetransition diagrams is to create a set of test cases such that all transitions are exercised at least once under test. Ø In high-risk systems, you may want to create even more test cases, approaching all paths if possible or create test cases for some or all of the invalid state/event pairs to make sure the system has not implemented invalid paths. 29

State-Transition Tables (Cont. ) Ø The advantage of a state-transition table is that it

State-Transition Tables (Cont. ) Ø The advantage of a state-transition table is that it lists all possible state-transition combinations, not just the valid ones. Ø When testing critical, high-risk systems such as avionics or medical devices, testing every statetransition pair may be required, including those that are not valid. Ø Creating a state-transition table often unearths combinations that were not identified, documented, or dealt with in the requirements. It is highly beneficial to discover these defects before coding begins. 30

State-Transition Tables (Cont. ) Ø Using a state-transition table can help detect defects in

State-Transition Tables (Cont. ) Ø Using a state-transition table can help detect defects in implementation that enable invalid paths from one state to another. Ø The disadvantage of such tables is that they become very large very quickly as the number of states and events increases. Ø In addition, the tables are generally sparse; that is, most of the cells are empty. 31

Contoh Software Testing ØSILK CENTRAL http: //www. borland. com/Products/Software-Testing/Test-Management/Silk. Central? gclid=Cjw. KEAjw 4 Sr.

Contoh Software Testing ØSILK CENTRAL http: //www. borland. com/Products/Software-Testing/Test-Management/Silk. Central? gclid=Cjw. KEAjw 4 Sr. BRDP 483 Gvre. Dr 2 ASJAD 5 s. CIuc. EXCe. Yd. WJENRpltmoiy. W 92 C 1 v 4 tyf 9 mx PCERKv-Rnho. CVP_w_wc. B Ø The open test management solution which unifies all test assets into one easy-to-use planning, tracking, reporting and execution hub. Ø Silk Central enables you to gain control, collaboration and traceability across all areas of your software testing, whether your methodology is Agile, Traditional or hybrid. Silk Central provides integration of requirements, manual and automated tests, defect tools and your test execution, giving full traceability of the quality of your software testing regardless of role. Ø 32

ØTESSY The Invaluable Test Tool Ø Ø Ø Ø Ø http: //www. hitex. com/index.

ØTESSY The Invaluable Test Tool Ø Ø Ø Ø Ø http: //www. hitex. com/index. php? id=module-unit-test&L=0&gclid=Cjw. KEAjw 4 Sr. BRDP 483 Gvre. Dr 2 ASJAD 5 s. CIuee. IJVq 3 L 72 Hv. Wvc 9 MVLY 9 FGuayri. Z 4 ZI 7 b. Aa 9 KJ 03 ho. Comnw_wc. B New: TESSY V 3. 2 released! Automated unit / module testing of embedded software Traceability of requirements Component testing = Integration testing of the units Easy to begin using - no script language to learn Test drivers and stubs built automatically Ideal for regression testing For certifications according to IEC 61508, ISO 26262, DO-178 B, and other standards Includes the Classification Tree Editor (CTE) for Test Case Specification 33

Software Quality: Tools Ø Ø Ø Ø Handle standards using Risk. CAT l Standards

Software Quality: Tools Ø Ø Ø Ø Handle standards using Risk. CAT l Standards like IEC 61508 or ISO 26262 comprise of several hundreds of possible measures. Risk. CAT helps to select and comment the measures of IEC 61508 and other standards. Static software analysis l Static software analysis generates investigates the source code of a program. This may reveal questionable constructs in the code, or allows calculating metrics. Advanced techniques point to actual errors that will occur during runtime if not fixed. Static software analysis using DAC. l The Development Assistant for C (DAC) checks coding rules like the MISRA rule set, calculates metrics, displays call graphs, etc. Static software analysis using PC-lint. The command line tool PC-lint checks C / C++ source code. Works across modules. Supports MISRA C and C++. Test case specification using CTE l Specify your test cases using the Classification Tree Method (CTM) which is supported by the Classification Tree Editor (CTE). Unit / module / integration testing using Tessy l Tessy provides automated unit / module / integration testing of embedded software written in C/C++ directly on the actual target hardware. It determines code coverage and generates test documentation. http: //www. hitex. com/index. php? id=1722&L=0%2 F%2 Fasset%20%E 2%80%A 6%2 F%2 F%2 Fass ets%2 Fsnippets%2 Freflect%2 Fsnippet. reflect. php%3 Freflect_base%3 D%5 C%27%5 C%22 34