Home

User Manual - glasnost.itcarlow.ie

image

Contents

1. 2 Click on Object Create 3 Fill the fields e Through lt lt and gt gt buttons you can change the information of the different parameters e You can use the wand button i to auto generate the inputs e You need to provide a name for the object Object Name lusert 4 Click on OK 12 17 JUnit Test Generator 15 04 10 User Manual 5 5 Add a new Instruction Needs to have opened a Java file 1 Click on a public method 2 Click on Instruction Create 3 Here you can choose between the asserts or a custom code e Asserts Choose the object to use from the options fill the parameters and in case you need it add some extra code at the end x Assert True se D getPassword Rest ofthe code equals secret Assert False user2 gt John Custom Code e Custom Code just write your code in the field next to Custom Code option 4 Click on Save any of them 13 17 JUnit Test Generator 15 04 10 User Manual 5 6 Edit an Instruction Needs to have opened a Java file 1 Click on a method that has instructions associated 2 Click on the instruction that you want to edit 3 Click on Instruction Edit Selected assertTrue user1 getUserName equals Sergio user2 getUserName equals Doe 4 Modify the fields you want 5 Click on Save 5 7 Delete an Instruction Needs to have opened a Java f
2. JUnit Test Generator 15 04 10 User Manual User Manual JUnit Test Generator I T Carlow Software Engineering Bachelor Degree With Honours Sergio Alcocer Vazquez C00132732 1 17 JUnit Test Generator 15 04 10 User Manual Table of Contents Hr TMIPOCUCH ON x z este tean A E bata teas bos leualeas E E AE 3 TeMs Wella Ss Wnt LA EE E E A A E E E E 3 1 2 Why is JUnit or reusing tests USCfUI 0 0 eee eecccesceesceeeseeceeeceseeesseceseeceseecnseeeseeeeeeseneeeeeneaaes 3 2 Application Features and Code Constraints cccccccccesseesseessneeeseeeeeeeeecenseceseceereeeseeenaeeeeeseeeeeeenes 4 3 User Manual usages x chet a n a datccees coon estonia huss ose ee ca eeck lesa once bees lec eccdens 5 A Mentan ene erno Uos da pane R E E ROR ER an Sodas eae ed danced recede oat 6 DOW Ko KARONE ARAE E eee eet ee SE A E a eve E S EA eee Boas Seacrest cea Paar os 8 5 1 Create an Skeleton with the application ccccccccccsscesssceeseeesteceeeecsseeceeeeseeeeeeesnteeeeesssaes 8 Silly e Set Filets packat esercente i ei a at E stein Te E eee a 8 51 226 Add an importes a E estado eases E T eee 9 S3 cr Adda CONSUUCLOR SS sie coszs 5 cdsedhenssdesvessl dates piodidadiecvves stoudedechantecdeedunbeah S a TES 9 Se see Add a method dinier nnee a E E aids A O R a ths 10 5 1 5 Create the skeleton once finished sssssseessessesseseeseesreseesetsessessesresestesersessesseessee 10 5 2 Open a Java File
3. ic class User TODO Write your own class properties public User String arg0 String argl TODO Write body public String getPassword TODO Write body public String getUserName TODO Write body public void setPassword String arg0 TODO Write body public viod setUserName String arg0 TODO Write body 16 17 JUnit Test Generator 15 04 10 User Manual Appendix 2 Example of code to add to the Randomizer class to generate Objects of type User randomly public Object getUser String letters new String abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPORSTUVWXYZ String username new String String password new String for int i 0 i lt 10 i username letters charAt int Math random letters length password letters charAt int Math random letters length return new String new User username password 17 17
4. ile 1 Click on a method that has instructions associated 2 Click on the instruction that you want to edit 3 Click on Instruction Delete Selected assertTrue user getl assertFalse user2 gel 14 17 JUnit Test Generator 15 04 10 User Manual 5 8 Generate the Test File Needs to have opened a Java file 1 Click on File Generate Test String String Book String getPassword String getUserName 2 Browse where you want it to be created and Save 5 9 Add a new type to the Randomizer With the application is given a library Randomizer jar and its Source Code This library is the one used to generate automatically the types of the fields If your code is using a type that is not in the Randomizer and you use the wand button while creating an Object it would give a warning message If you want those types to be generated you should create those methods and compile Randomizer The methods should be public and return some Java built in type that by calling toString it returns how it should created For example if we want to add to the Randomizer the User we should create the function getUser as shown in Appendix 2 Once the code is ready build the jar file and copy it to _lib folder 15 17 JUnit Test Generator 15 04 10 Appendix 1 User Manual Code generated by the application showed in the HowTo section package hotel import java util ArrayList publ
5. ind the error much faster Otherwise you would realise that there is a problem when joining all together and you will have to scan each single class to check if the error is there or not Storing JUnit Tests lets you modify the class You can add new methods and then use the application to add more tests to those new methods without having to start over It also lets you modify the implementation of a method and then reapply the test to check if you have broken something down 3 17 JUnit Test Generator 15 04 10 User Manual 2 Application Features and Code Constraints The application has two working modes The first is the skeleton generator Through the application s GUI you would be able to define the name of the class the package of the class the imports that it needs the constructors and methods with their parameters Once you have add all the methods and constructors imports and package that you want the application allows you to dump that information into a Java file The second is the JUnit Test Generator it self Through the application s GUI you would be able to load a Java File Once loaded you can start creating Objects to use on the test s instructions create Instructions or you can Load a previously saved state When you finish or just before closing the application you can save your progress or and generate the test file The Java Code had this constraints Cannot use extends or implements Ca
6. n 5 8 Note This application uses a library called Randomizer which is filled and compiled by YOU This library is the one that allows the auto generation of the inputs on the creation of the objects Check section 5 9 5 17 JUnit Test Generator 4 Menu e File o Open o New o Generate Test o Export Skeleton o Add Import o Set Package e State o Load o Save 15 04 10 User Manual Allows to open a Java file to start adding TestCases and objects Only visible before choosing either the option Open or New Allows to create a Java skeleton file with the methods desired Only visible before choosing either the option Open or New Takes all the information of the tests and generates a JUnit Java file Only visible once a file has been opened Generates a Java file skeleton with the methods imports and package given Only visible once the option New has been chosen Adds an Import to the import list of the Skeleton to be created Only visible once the option New has been chosen Sets the package of the Java file to be created Only visible once the option New has been chosen Only visible once a Java file has been opened Loads all the test information previously stored from a file Stores all the test information for future runs 6 17 JUnit Test Generator Object O Create Instruction O O O Create Edit Selected Delete Selected 15 04 10 User Manual Only visible o
7. nce a Java file has been opened and a Constructor has been selected Creates an object to be used in the tests Only visible once a Java file has been opened and a method has been selected Allows to create an instruction as an assert or a custom code one Allows to edit the selected instruction Only visible when an instruction has been selected Deletes the selected instruction Only visible when an instruction has been selected HAT JUnit Test Generator 15 04 10 User Manual 5 How To 5 1 Create an Skeleton with the application 1 Run the application 2 Click on File gt New 3 Choose a folder an a name for the file to create User java for example 4 Follow 2 1 X instructions 5 1 1 Set File s package 1 Click on File Set Package 2 Write the package and click OK Creating User Method and Constructors Export Skeleton Add Import 8 17 JUnit Test Generator 15 04 10 User Manual 5 1 2 Add an Import 1 Click on File Add Import 2 Write the package and class to import and click OK Set Package 2 Import text java util ArrayList 5 1 3 Add a constructor 1 Click on Method and Constructors New Constructor 2 Write the access public or private on the first Field 3 Write the type of the n parameter on the last Field and click on gt gt 4 Repeat step 3 until you finish then click on Save Access ConstructorName Pa
8. nnot use abstract final etc modifiers only public or private Cannot throw exceptions Cannot declare more than one element in the same line e g private String name password you should split it in two instructions 4 17 JUnit Test Generator 15 04 10 User Manual 3 User Manual usage In the next section Menu section there is a list of all the options that can be available on the application a small description of what they do and when they will be visible to the user The last section just before the Appendices is a How To in which is detailed all the operations that can be performed in the program step by step If you follow it after finishing the section 5 1 and all its sub steps and sub states you should end up with a skeleton of your class ready to be filled up with code In section 5 2 you should open the file you want to create the tests for then you can either open the just generated file through section 5 1 5 or any simple Java file Once it gets loaded the methods prototypes would be listed on the left column Now is when you need to create instructions and associate them with a method To do that you first need to create at least one object you can check the steps out in this manual During this process you can either load or save the state WARNING Loading a state removes all previous information Once you have finish just generate the Test file To do so follow the How To sectio
9. ramType1 ParamType2 Si public lt lt boolean gt J save 9 17 JUnit Test Generator 15 04 10 User Manual 5 1 4 Add a method 1 Click on Method and Constructor New Method 2 Write the access public or private on the first Field 3 Write the returned type on the second Field 4 Write the name of the method on the third Field 5 Write the type of the n parameter on the last Field and click on gt gt 6 Repeat step 5 until you finish then click on Save public viod Access ReturnedType MethodName ParamType1 ParamTypez public viog setUserNam 5 1 5 Create the skeleton once finished 1 Click on File Export Skeleton 2 The file would be created in the folder specified at the beginning It is possible to see the example in the Appendix 1 10 17 JUnit Test Generator 15 04 10 User Manual 5 2 Open a Java File 5 3 1 Run the application 2 Click on File Open 3 Browse the file that you want to create the Test for Load or Save the progress of the Test Class Needs to have opened a Java file 1 Click on State Load or State Save 2 Choose the file to read write Instruction er String String ring getPassword n oetiiserName i 11 17 JUnit Test Generator 15 04 10 User Manual 5 4 Add a new Object Needs to have opened a Java file 1 Click on a Constructor in the list on the left
10. rio E e Sel anads laa E ies a la cate EE E E E E EEE 11 5 3 Load or Save the progress of the Test Class cccccccscccssecesseeeseeeeseeeeeeesecesseeesseeseeeesseeeees 11 SA oe Add a Mew Object aeni enr e aie ioe TEE E Eaa ta Te dota A R 12 DO vert Add a mew INSUC ON see sian a a e aa a a E e e aa RE e 13 5 6a ri Eitan InStHUCtiOMiis5v wraszvsersiees e e aeea e E E Ca E ER 14 5 7 Delete an MSIrUCHO Ns e a ae ara aaa E a A A E r aea aa aa aa 14 AEA Generate the Dest A E TE EA E 15 5 9 Add a new type to the Randomizet eccceeccesssceessceeneeseseceseeceseecneeeneeenecenneeeeesenneeeeeeees 15 Appendix Taaie i A a AE E E A E RE a E E A 16 aN a oleta bb aS E E E E E E N 17 2 17 JUnit Test Generator 15 04 10 User Manual 1 Introduction JUnit Test Generator is an application that allows the user usually a software developer to generate JUnit Tests in a semi automatic way in an early stage of the project It also stores the information of the tests cases instructions associated to each method to allow the user modify them edit delete and create instructions With the application you can even create a simple skeleton for your application from scratch 1 1 What s JUnit JUnit is a framework to create Unit Tests for Java language that allows testing the correct functionality of any class 1 2 Why is JUnit or reusing tests useful JUnit tests single classes what reduces the search space helping you f

Download Pdf Manuals

image

Related Search

Related Contents

motorola W315 - Compare Cellular  Aufwickeleinheit Serie W SP 500/800  Samsung Galaxy Pocket Bruksanvisning  Product Manual  ViewSonic VS12680 User's Manual  DLLR Training Guide User`s Manual  Lenovo H 50-50    ATV58 FR    

Copyright © All rights reserved.
Failed to retrieve file