Make my C++ Assignment using GCOV Code for the course CSCI222 System Development of University of Wollongong
Question - University of WollongongAssignment 1: “Testing†AIM The aims of this assignment are to: •Provide experience in the use of a modern Integrated Development Environment (specifically NetBeans running on a Linux platform) for the development of C++ applications; •Provide additional experience in the design and implementation of simple C++ classes; •Introduce the "Test Driven Development" style for program development; •Use program testing tools including unit testing (cppUnit) and code coverage testing. On completion of this assignment, you should be able to: 1.Make effective use of an IDE for C++ development. 2.Develop a simple project in "test driven development" style. 3.Utilize
...Read More
the cppUnit unit test framework to run test suites on new components of application code; 4.Utilize the gcov code coverage tool to verify the extent to which a complete application has been exercised The assignment does require that you use the NetBeans IDE as the standard C++ development environment. The Ubuntu Linux computer systems in laboratory will have this system installed.
You should read the description of the Point-Of-Sales (POS) System before reading these task details. You are to implement the application described in those notes, and then produce a report on your application, and your development process. Your report should demonstrate that: •appropriate use was made of the IDE, •you followed an iterative style of development creating and testing component classes prior to assembling them into complete programs •you tested your final programs thoroughly. You prepare a report on your final code, your development process, and your testing. This report should be prepared in a word processor (Microsoft Word, or Open Office Word Processor) and should contain formatted listings of code, code coverage testing listings, screen shots, and segments of captured console output. The final report is submitted as a PDF document. It is intended that you learn to use the IDE (and, if appropriate, learn to exploit the integrated source level debugger). Your report on your assignment work should include screen shots illustrating your code being developed in the IDE. You will need to implement a number of classes. In addition to application specific classes, you may need some standard classes from the STL and iostream libraries. Of course, there is no need for you to do any testing of such standard classes. Remember that Test Driven Development (TDD) is more about design than testing. The TDD approach encourages you to think in terms of simple, orthogonal classes that can be developed and tested in isolation and which can then be assembled into a complete program. You will create Test classes (these are all specialized CppUnit::TestFixture classes) that test the functionality of your application classes. CppUnit classes, their more important methods, and the helper macros are covered briefly in the lecture materials. cppUnit is further documented at its SourceForge home. 1Your assignment report should include formatted listings (header and code files) for your classes – both the application specific classes and their associated test classes. If you do “refactor†your 2classes many times, you need only include final versions of the class and its test class. When http://cppunit.sourceforge.net/doc/1.11.6/cppunit_cookbook.html 1 Reminder: you can get formatted listing via the NetBeans “print as HTML†option.2
presenting a class it is best to provide a brief summary of the role of the class, its header file, and then its implementation file. You should do proper code-coverage checking of your program. You need to run your programs, possibly many times, to verify that you have executed all the different processing options. Your report should include formatted listings of your application, some captured input and output from console sessions, and some gcov code coverage reports. You should edit segments out of your console sessions and code-coverage reports – there is no need to include the full listings which can be very long. You are to submit a PDF formatted report file. This report file should be prepared in a word processor such as Microsoft Word or Open Office’s word processor, and "printed" to PDF file. 3The report is to have sections on each of your classes, and sections for the program(s) that make up the overall application. Each "class" section should include the complete listing of the code of your class. In addition it should contain listings of the corresponding tests class. You should also include a report on your development strategy - e.g. were several iterations used to develop the class, was it necessary to revise the class at a later stage in the development project, etc. The section on testing the program(s) should include some recordings showing interaction with the program (just the input commands and output responses as captured from a session), and edited excerpts from gcov profiling summaries. The outputs from gcov are too lengthy to be included in their entirety, include only excerpts. Before you get any marks for any component, there must be evidence supplied that the component works and has been thoroughly tested. Even if your component works, you may lose marks for coding defects. •Overall presentation of report: 1 mark •Coding of applications and classes : 4 marks oClasses: 2.5 marks oOverall application: 1.5 marks •Effective use of testing tools and effective development strategy, coding : 5 marks Note that a well prepared report on this task might be a useful addition to the "work portfolio" that you are preparing 3to show potential employers.
oC++ usage (properly constructed class - header file definition, conditional include macros, appropriate style of member declaration, consistent naming conventions, consistent coding style, ...) : 1 mark oUnit test test suites for classes : 2 marks oCode coverage testing : 1 marks oDevelopment strategy, use of iterative development style etc: 1 marks Appendix A Development Proposal Point-Of-Sale (POS) System
From one supermarket, FairPrice has grown to become Singapore’s largest retailer, with a network of more than 230 outlets comprising FairPrice supermarkets, Cheers convenience stores etc. In order to capture the daily sales transaction, the supermarket has decided to employ you to implement an electronic Point Of Sale system. It is critical for the supermarket to have a high-quality system in place due to various reasons such as security, performance, availability and so on. Therefore, you are asked to use a test-driven approach to develop a POS System which needs to meet the following requirements. Functional Requirements 1.To m a i n t a i n 2 f i l e s , o n e f i l e c o n t a i n s t h e l o g i n a c c e s s e g : C a s h i e r ’ s d a t a ( c a s h i e r ’ s I D , encrypted password) and second file to store transactions details (e.g. item description, unit price , quantity purchased, date purchased etc.). The format of those files is your choice. In your report you should include the test data that are stored in those two files. 2.The system shall ask the cashiers to login with their ID and password. The system then checks this information against the cashier data, and displays an appropriate error message if either the cashier ID or the password is not correct. 3.If the system determines that the cashier's password is invalid, the cashier will be required to re-enter the password. If the cashier is unable to successfully enter the password after three tries, their record is marked as “locked†and they are not allowed to login in the system. 4.The system shall encrypt and decrypt cashier passwords using a Caesar cipher 45.The system shall allow the cashiers to change their login password. A valid password must contain at least 8 characters and must include at least a number and a letter. Details of a Caesar cipher are available at http://en.wikipedia.org/wiki/Caesar_cipher4
6.Upon successful login, the system shall allow the cashier to use the system as an electronic cash register. 7.The electronic cash register will have the following interactive menu, allowing you the options of: a)Add new sales transaction b)Remove sales transaction c)Edit sales entries d)Inquire or search sales transaction e)Daily sales summary report f)Monthly sales summary report g)List the best and worst selling item in term of quantity sold h)List the best and worst selling item in term of total price purchased i)List sale items in ascending or descending order j)Administration – add / remove cashier k)Administration – change password l)Quit The system allows new sale details to be individually entered and then stored in a text file as the following format: [Item description]:[Unit Price]:[Quantity Purchased]:[Date Purchased] eg: DutchLadyMilk:2:6:25Jan14 ABCDetergent:3:5:25Jan14 EverReadyBattery:1:3:26Jan14 ThaiRice:4:1:27Jan14 XZYEgg:2:20:27Jan14 The colon (:) character is used to separate each piece of information. Should there be an error during sales entries by the cashier, the system has the options to either remove or edit the sales transaction. 9.The POS also allows the cashier to search the sales transaction based on date purchased. At the end of the day, the cashier can use the POS system to generate a daily sales summary report as well as Monthly sales report shown below. The total sales of the day should be computed by performing the summation of all the products purchased for the day with their Unit Price multiplied by their respective Quantity Purchased. An example of the Daily Sales summary report would be: Date Total Sales 24Jan14 $350 25Jan14 $238 26Jan14 $451 27Jan14 $239 Grand Total $1279 Monthly Total Sales Nov 13 $9200 Dec 13 $8400 Jan14 $9350 Feb14 $11800
The POS can list the top 3 best and worst selling item in term of quantity sold per day Eg: TOP 3 items with the highest Quantity sold Date: 14th Jan 2014 Ranking Item Qty 1.ThaiRice 200 2.Coke 156 3.DutchLadyMilk 100 Qty Shoe 4 The POS can base on total price purchased of a specific item and highlight the top 3 selling items per day. Eg: Date: 14th Jan 2014 Ranking Item Total price 1.F&N Drinks $500 2.Amos Cookies $356 3.DutchLadyMilk $140 The system can sort transaction details by various fields eg: item name, transacted date etc in ascending or descending order 13.The system has administrative function to allow administrator add new cashier record such as cashier name, ID, password & role as well as to delete cashier record when one resigns. 1.The system is to be implemented in C++ and is to run on a Linux OS. 2.The system is to use a simple textual “menu-select†style of user interface. Use of Integrated Development Environment – NetBeans Yo u a r e t o c r e a t e y o u r s o l u t i o n a s a s e t o f C + + a p p l i c a t i o n p r o j e c t s w i t h i n N e t B e a n s . •Yo u a r e s t r o n g l y a d v i s e d t o w o r k i n t h e l a b o r a t o r i e s f o r t h e s e h a v e t h e N e t B e a n s e n v i r o n m e n t already set up and the necessary libraries (such as the cppUnit framework library) installed. •Yo u c a n i n s t a l l t h e d e v e l o p m e n t e n v i r o n m e n t o n y o u r o w n m a c h i n e a n d d o s o m e o f t h e w o r k a t home; but you really should participate in scheduled laboratories as well.
•It is fairly easy to install the NetBeans system on Linux – you must first install a JDK 1.6.x system (and change system settings so that it is this version of Java that is used by default – not the much older version typically installed with a Linux system) and then you can download and install NetBeans (www.netbeans.org). Of course, you must also have standard C++ development tools (g++ etc) installed on your Linux system. •Installation on a Windows system is a little more involved (well, it’s trivial if you just want Java and/or PHP development – the problems relate to configuring its connection to a working C++ development environment). You must once again install Java JDK 1.6.x. You must also install a C++ development environment – cygWin is the common choice but the (free) “express edition†of Microsoft’s Visual C++ could be an alternative. You may have to add the cppUnit library as a separate step (it is even possible that you will have to recompile this library). •Once you have Java 1.6 and some C++ environment both working, you can download the Windows version of NetBeans. The netbeans.org site has instructions on how the installation is done. You will need to edit some environment variables (instructions are given at netbeans.org site) – environment variables are accessed via Windows/Control Panel/System Properties/Advanced/Environment variables. These environment variables tell NetBeans about the C++ environment that it is to use. •Installation of the software on your own machine is not considered part of the assignment. Time spent on such an installation (which could be quite large) does not count to the expected 12-hours per week of work for subject CSCI222. Each class, and its associated test class, should be developed as a separate project. Within NetBeans’s “project†view you can copy and paste header and implementation files from one project to another; the files are not duplicated – the operation simply creates appropriate references. 5Changes to a class within its own project will then automatically propagate through to any projects that reference that class. The projects for classes and associated unit testing code will need to have compiled and linked properties both adjusted to include the cppUnit libraries (the header files for compile time, the compiled code at link time). The lecture notes on testing and cppUnit contain illustrations showing how this can be done. Use of cppUnit The file with the TestDriver code should be physically copied into each project that involves unit testing. This code is never changed. As noted above, you must edit the C++ “compile†and “link†properties of a project to reference the include directory containing the cppUnit header files and the libcppUnit.a file respectively. The lecture notes contain an illustration. If you did the exercises in the laboratory, you will have learnt how to configure a project to use extra libraries. The cppUnit classes will be subclasses of CppUnit::TestFixture. Use CPPUNIT_TEST_SUITE and CPPUNIT_TEST macros to build the TestSuite instance for this class. Work incrementally on each class. Define some operations in your class and add a test function to your tester class. Use CPPUNIT_ASSERT macros in your tester class to validate operations. Note that this impacts on the file path names for header files that are needed for #include “…†statements.5
Iterate through test/refactor/test until the new operations are working correctly (at the same time retesting all previously implemented operations). Use of gcov code coverage tool gcov is a part of the gnu suite of C/C++ tools; if you are using a different C++ environment you will have to identify the equivalent code coverage tool and resolve how it is used. The lecture notes explain the usage of gcov. If you did the exercises in the laboratory, you will have learnt how to configure and run an application with code coverage incorporated, and how to generate actual code coverage reports. Generate reports that show graphically the number of times code corresponding to individual source statements has been executed. gcov reports are long – it will suffice to include just a couple of screen shots showing parts of reports (or copy & paste some segment of text from a gcov report into your report and tidy formatting). Suggested tasks 1. Complete exercises on basic use of NetBeans/C++ development. Start your analysis of the system requirements. 2. Complete exercises involving partially implement Point and Bitmap classes and the use of cppUnit and gcov. Implement some basic functionalities. 3. Refactor/refine existing code and implement the remaining functionalities. Develop unit test classes. Begin work on A1.pdf report with a draft of the sections presenting the classes, the use of cppUnit, and your incremental development approach. 4. Test the whole system and fix bugs if found. Perform code coverage testing. Complete and submit the report. ...Read Less
Solution Preview - No Preview Available. <b>Check Original File</b>