UML methodology for automatically generated test case based

UML Based Unit Level TestingUnified Modeling Language (UML) Submitted by: Sonia KanwalRoll Number: ms170400767Submitted by: Naveed Ali AnjumRoll number: ms170401250Virtual University Pakistan semester PaperSoftware Quality Assurance AbstractIncreasing numbers of software developers are using the Unified Modeling Languauage(UML) and associated visual modeling tools as a basis for the design and implementation of their applications.Anyone who has been involved in any part of software engineering will have using some form of testing.It is necessary to  test the units of software during development. UML stands for Unified Modeling Language.Now a days increasing number of software developers are using the unified Modeling Language (UML) and associated visual modeling tools as a basis for the design and implementation. In this paper we present our approach to modeling components and their interactions. A standardized way of modeling the static structure and dynamic behavior of components and their interfaces is called Unified Modeling Language (UML).UML (Unified modeling language) is widely used as a system or unit level specification in embedded system design. Now a days UML analysis and validation specification is becoming a challenge due to increasing complexity in software engineering. UML (Unified Modeling Language)activity diagram is promising to modeling the overall system behavior. . This article presents a methodology for automatically generated test case based on various model checking techniques.It makes three primary contributionFirst we propose coverage driven mapping rules that can automatically translate activity diagram to formal models.Next, we presents a procedure for automatically translate activity diagram to formal models.Finally, we apply various model checking based test case generation techniques to enable efficient test case generation.Testing can be considered as an f mechanism that checked a piece of software or a whole software is working correctly as specification of its functional requirements. The majority of testing team has generally been left late in the software engineering process. Introduction Software testing is an action which attempt to find bugs manually or through automation tools.Historically software testing has been consume about 50% of development cost and development time. This point clearly show that software testing is very importandt aspect in software development. Software testing still remains a subject area we have relatively  little knowledge of compared to other aspects of software engineering and software development.This lack of knowledge is easily tied to the complexity of software testing. For example in order to completely test a relatively simple program, the number of test cases needed might be in the tens of thousands. Another problem often faced while testing is the quality of testing produced by a programmer. This is due to a misconception in meaning of testing. Many programmers believe that the process of testing how that the program work correctly and the program does not contain any error. The problem with the first definition is that it is impossible to say that or prove that the program or software does not contain any error. And the problem with the other definition is that if you show that a program work properly or correctly and it does not contain any error then you are in danger of discovering hidden or unwanted features in the program which clearly show that the program is incorrect and contain bugs or errors that disturb the actual working of the Software.A more appropriate view of testing would be to move from the notion of showing that a program works to a notion of finding errors in a program. This is far more practical as the assumption (that a program contains errors) is true for almost any program.The factors of testing include:Unified Modeling language definition (UML) a standardized way of modeling the static and dynamic structure and behavior of components and their interfaces. As a result, developers are implementing large numbers of components.UML Based TestingThis small section discusses about UML based unit testing techniques and approaches which are usually based on techniques, bugs, issues, errors and approaches discussed above. Most of the time, the techniques and approaches are examined to match particular UML diagrams selected for the works. Usually there is an implementation of tools for the approaches and techniques.Introduction of unit Testing:In computer system and programming, unit testing is a software testing method by which individual units of software, program, and source code. Sets of one or more computer program/software modules together with associated usage of data, control of data, usage of procedures, operating of procedures are tested completely or separately to determine that whether they are fit for use and working properly without any problem or without creating any error.The programmer can view a unit of program as the smallest testable part of an application, software or program. In procedural programming, a unit can be considered an entire module, but it is more commonly considered an individual function or method or procedure. In Object Oriented programming, a unit of program can be considered as an entire interface, such as a class or an individual method. Unit testing is a short code fragmentation created or developed by programmers during the development process. It is the basic form of component testing. Generally, each test case is independent from the others.  Substitutes such as method stubs, mock objects, fakes, and test harnesses can be used assist or implementing testing a module in isolation. Unit test are generally written by software developers or programmers to ensure the quality of unit and the code meets its design and behaves. Because some classes may have references to other classes, testing a class frequently spill over into testing another class. A common example of this is classes that always depend on the database. In order to test the class, the tester often writes code that interact with database and check the code is error free or working properly. This is a mistake because unit testing is not usually go outside of its own boundary, and especially not cross network boundaries because this can create unacceptable performance problems to the unit test. Crossing such unit boundaries turns unit testing into integration testing, and when such test cases fail, it may be unclear which component is causing the failure. The independent unit can be more thoroughly tested that may have been previously achieved. This results in a higher quality unit testing that is also more reliable and more maintainable.Unit testing is used for different purposes and applied at different stages of a software process or project. For eample functional testing , system testing, Performance testing, Integration testing etc effect on different way on project.Functional Testing:Functional testing focuses on validating that the main functions of a system fulfill their requirements.System Testing:System testing validates the most common usage path of a system operate as expected prior to release.Performance Testing:Performance Testing is used to validate that the system meets its non-functional requirements by operating effectively under different load and stress conditions.Figure 1: Comprehensive Unit Testing is a better foundation for other forms of testingAdvantages of Unit Level Testing:The goal of unit testing is to isolate each part of the program and show that the individual parts are correct and working properly.There are many advantages of unit testing so the developers used unit testing in any software engineering project. These advantages are as follows:Faster Development:When you write you will spend less time of debugging and you will have confidence that changes to your code actually work. This confidence allows you to get more refactoring code and adding new features.Faster Debugging:In unit testing to debug or resolve a functional test Without unit testing these tasks may have failed and takes a long time to track down.Better Design and Documentation:Writing unit tests forces developers that their code is going to be used and has generally resulted in better design and even better documentation. Better Feedback Mechanism:Unit tests also provide other developers with an instant mechanism of evaluating whether other parts of the code base are meeting their requirements or are still under development. Changes in test environments may sometimes cause problem with the code base, and continuous reporting of the unit test suites as a complete can help to show the state of the test environment.  Good Regression Tool:A comprehensive unit test suite enables major refactorings and restructuring of the code to be completed with greater confidence. As long as unit tests continue to pass, developers can be confident that their changes to the code do not have a negative impact on the functionality of the application as a whole. Find problems early:Unit testing finds problems early in the development process. This includes both bugs in the programmer’s implementation. The cost of finding a bug before coding begins or when the code is first written it is lower than the cost of detecting, identifying, and correcting the bug later.In unit tests it is  allow the location of the fault or failure to be easily traced.Facilitates change:Unit testing allows the programmer to regenerate or facilitate the  code or upgrade system libraries at a later date, and make sure the module still works correctlySimplifies integration:Unit testing may reduce unneseccary in the units themselves and can be used in a bottom testing style approach. By testing the parts of a program first and then testing the sum of its parts, integration of the system becomes much easier.Documentation:Unit testing provides a sort of living documentation of the system. Design:When software is developed using a test-driven approach, the combination of writing the unit test to specify the interface plus the refactoring activities performed after the test is passing, may take the place of formal design. Reduce Future Cost: Many studies have proved that it costs generally more money to fix a bug found later in its release than earlier in its development. A good unit test suite will uncover basic bugs early on in the development cycle, reducing the potential for other bugs and reducing cost of future maintenance.Disadvantages of Unit Testing:Sometimes unit testing create different issues such as follows:Decision problemTesting will not find every error in the program, because it cannot execute every execution path in any but the programs. The same is true for unit testing. Unit testing should be done in conjunction with other software testing activities, as they can only show the presence or absence of particular errors, they cannot prove a complete absence of errors. To guarantee correct behavior for every execution path and every possible input, and ensure the absence of errors, other techniques are required, namely the application of formal methods to proving that a software component has no unexpected or alternate behavior.Not integration testing:An elaborate hierarchy of unit tests does not equal to integration testing. Integration with peripheral units should be included in integration tests, but not in unit tests.Combinatorial problem:Software testing is a combinatorial problem. For example, every decision statement requires at least two tests: one with an outcome of “true” and one with an outcome of “false”. As a result, for every line of code written, programmers often need 3 to 5 lines of test code. In addition, code for a unit test is likely to be at least as buggy as the code it is testing.Realism:Another challenge related to writing the unit tests is the difficulty of setting up realistic and useful tests. It is necessary to create relevant conditions so the part of the application being tested behaves like part of the complete systemRecord keeping:To obtain the intended benefits from unit testing, it is needed throughout the software development process. It is essential to keep careful records not only of the tests that have been performed, but also of all changes that have been made to the source code of this or any other unit in the software. Platform difference:Unit testing embedded system software presents a unique and different challenge. Because the software is being developed on a different platform than the one it will eventually run on, you cannot readily run a test program in the actual deployment environment, as is possible with desktop programs.External work.Unit tests is to be easiest when a method has input parameters and some output. It is not as easy to create unit tests when a major function of the method is to interact with something external to the application. For example, a method that will work with a database might require a link of database interactions to be created, which probably won’t be as comprehensive as the real database interactions.Example:Here is a set of test cases that specify a number of elements of the implementation. First, that there must be an interface called Adder, and an implementing class with a zero-argument constructor called Adder_Imp. It goes on to show that the Addition interface should have a method called addition, with two integer parameters, which returns another integer. It also specifies the behaviour of this method for a small range of values over a number of test methods.import static org.junit.Assert.*;import org.junit.Test;public class TestAddition {    @Test    public void testSumPositiveNumbersOneAndOne() {        Adder adder = new Adder_Imp();        assert(addition.add(1, 1) == 2);    }    // can it add the positive numbers 1 and 2?    @Test    public void testSumPositiveNumbersOneAndTwo() {        Addition addition = new Adder_Imp();        assert(addition.add(1, 2) == 3);    }    // can it add the positive numbers 2 and 2?    @Test    public void testSumPositiveNumbersTwoAndTwo() {        Addition addition = new Adder_Imp();        assert(addition.add(2, 2) == 4);    }    // is zero neutral?    @Test    public void testSumZeroNeutral() {        Addition addition = new Adder_Imp();        assert(addition.add(0, 0) == 0);    }    // can it add the negative numbers -1 and -2?    @Test    public void testSumNegativeNumbers() {        Addition addition = new Adder_Imp();        assert(addition.add(-1, -2) == -3);    }    // can it add a positive and a negative?    @Test    public void testSumPositiveAndNegative() {        Addition addition = new Adder_Imp();        assert(addition.add(-1, 1) == 0);    }    // how about larger numbers?    @Test    public void testSumLargeNumbers() {        Addition addition = new Adder_Imp();        assert(addition.add(1234, 988) == 2222);    }}Explanation:In this case the unit tests, having been written first, act as a design document specifying the form and behaviour of a desired solution, but not the implementation details, which are left for the programmer or designer. Following the “do the simplest thing that could possibly work” practice, the easiest solution that will make the test pass is shown below.interface Addition {    int add(int a, int b);}class Adder_Imp implements Addition {    public int add(int a, int b) {        return a + b;    }}Unit Level Testing With the help of Diagram:Figure2:L Unit Level Testing Of ATM systemConclusion / Analysis So far there have been a lot of publications in software testing area. Focuses of the publications or requirements have changed over time. From problem domain analysis to design of techniques and approaches and then to the UML based testing, researchers have shifted their interests, as the concept and core knowledge of the area become more mature and popular. Along the way, there have been some conflicts in ideas, concepts, and opinions among researchers. However, the conflicts are presented as alternatives most of the time. It is possible to say that generally most works go in the same direction, since there is an agreement on fundamental concept regarding  software testing. Although researches in this area are still carried on by a lot of researchers, there are several new directions in researches, which have their roots in software testing. Model checking based on executable UML is one of examples of an attempt to apply testing techniques to test UML models. Unlike traditional model checking, this technique relies on symbolic execution of UML model. As it is analogous to program execution, concepts from object-oriented software testing and UML based testing can be applied. Another example is an attempt to adapt data flow testing for objectoriented software HR94 to aspect-oriented software Zhao03. This shows a good sign that researches in this area and closely related areas will continue and span in many direction

x

Hi!
I'm Alfred!

Would you like to get a custom essay? How about receiving a customized one?

Check it out