PMT PMT PMT emag@pmtsolution.net Editor s Desk PMT PMT 2001 emag@pmtsolution.net 1
egroups smiling PMT Review Co-Translation Project PMT P M T R e v ie w Software Design PMT 2001 emag@pmtsolution.net 2
P M T Re v ie w PMT 2001 emag@pmtsolution.net 3
PMT 2001 emag@pmtsolution.net 4
PMT 2001 emag@pmtsolution.net 5
CMM Capability Maturity Model cmm@pmtsolution.net CMM CMM maturity level key process area common feature key practice CMM CMM The key practices describe what is to be done, but they should not be interpreted as mandating how the goals should be achieved. common feature commitment to perform ability to perform activities p e r f o r m e d measurement and analysis v e r i f y i n g implementation KPA KP KPA CMM KPA PMT 2001 emag@pmtsolution.net 6
KP CMM PMT (practice) PMT 2001 emag@pmtsolution.net 7
the purpose of Software Quality Assurance is to provide management with ap- propriate visibility into the process being used by the software project and of the products being built. CMM P M T R e v ie w (practice) PMT 2001 emag@pmtsolution.net 8
Application CMM (Application) PMT 2001 emag@pmtsolution.net 9
Software Testing www.junit.org JUnit is a regression testing framework written by Erich Gamma and Kent Beck. It is used by the developer who implements unit tests in Java. JUnit is Open Source Software, released under the IBM Public License and hosted on SourceForge. Before we begin, it s worth asking why we should use JUnit at all. The subject of unit testing always conjures up visions of long nights slaving over a hot keyboard trying to meet the project s test case quota. However, unlike the draconian style of conventional unit testing, using JUnit actually helps you write code faster while increasing code quality by creating synergy between coding and testing. Here are just a few reasons for using JUnit: JUnit tests allow you to write code faster while increasing quality. Yeah, I know, it sounds counter-intuitive but it s true! When you write tests using JUnit, you ll spend less time debugging, and you ll have confidence that changes to your code actually work. Without tests, it s easy to become paranoid about refactoring or changing code because you don t know what might break as a result. By writing tests, you can quickly run the tests after changing the code and gain confidence that your changes didn t break anything. If a bug is detected while running tests, the source code is fresh in your mind, so the bug is easily found. Tests written in JUnit help you write code at an extreme pace and spot defects quickly. JUnit is elegantly simple. Writing tests should be simple - that s the point! If writing tests is too complex or takes too much time, then there s no incentive to start writing tests in the first place. With JUnit, you can quickly write tests that exercise your components. Once you ve written some tests, you want to run them quickly and frequently without disrupting the creative design and development process. With JUnit, running tests is as easy and fast as running a compiler on your code. In fact, you should run your tests every time you run the compiler. The compiler tests the syntax of the code and the tests validate the integrity of the code. PMT 2001 emag@pmtsolution.net 10
JUnit tests check their own results and provide immediate feedback. Testing is no fun if you have to manually compare the expected and actual outcome of tests, and it slows you down. JUnit tests can be run automatically and they check their own results. When you run tests, you get simple and immediate visual feedback as to whether the tests passed or failed. There s no need to comb through a report of test results. JUnit tests can be composed into a hierarchy of test suites. JUnit tests can be logically grouped into test suites containing test cases and other test suites. The composite behavior of JUnit tests allows you to assemble collections of tests and automatically regression test the entire test suite in one fell swoop. You can also run the tests any logical level within the test suite hierarchy. Writing JUnit tests is inexpensive. Using the JUnit testing framework, you can write tests and enjoy the convenience of the testing harness supported by the framework. Writing a test is as simple as writing a method which exercises the code to be tested and defining the expected result. The framework provides the environment in which the test can be run automatically and as part of a collection of other tests. JUnit tests increase the stability of software. The fewer tests you write, the less stable your code becomes. Tests validate the stability of the software and instill confidence that changes haven t caused a ripple-effect through the software. The tests form the glue of the structural integrity of the software. JUnit tests are developer tests. P M T R e v ie w JUnit tests are highly localized tests written to improve a developer s productivity and code quality. Unlike functional tests, which treat the system as a black box and ensure that the software works as a whole, unit tests are written to test the fundamental building blocks of the system from the inside out. Developer s write and own the JUnit tests. When a development iteration is complete, the tests are promoted as part and PMT 2001 emag@pmtsolution.net 11
parcel of the delivered component as a way of communicating, Here s my deliverable and the tests which verify it. JUnit tests are written in Java. Testing Java software using Java tests forms a seamless bond between the test and the code under test. The tests become an extension to the overall software. The Java compiler helps the testing process by performing static syntax checking of the unit tests and ensuring that the software interface contracts are being obeyed. JUnit is free. Design Of JUnit JUnit is designed around two key design patterns: the Command pattern and the Composite pattern. A is a command object. Any class that contains test methods should subclass the class. A can define any number of methods. When you want to check the expected and actual test results, you invoke any variation of the convenience method and pass a expression that returns to indicate the assertion is true. subclasses that contain multiple methods can use the and convenience methods to initialize and release any common objects under test. instances can be composed into hierarchies that automatically invoke all the methods defined in each instance. A is a composite of other tests, either instances or other instances. instances and instances can be added to a using the convenience method. The composite behavior exhibited by the allows you to assemble test suites of test suites of tests, to an arbitrary depth, and run all the tests automatically and uniformly to yield a single pass or fail status. Now that we ve written a test suite containing a collection of test cases and other test suites, we can run either the test suite or any of its test cases individually. Running a will automatically run all of its subordinate instances and instances. Running a will automatically invoke all of its defined methods. PMT 2001 emag@pmtsolution.net 12
JUnit provides both a graphical and a textual user interface. Both user interfaces indicate how many tests were run, any errors or failures, and a simple completion status. The graphical user interface displays either an AWT-based ( ) or Swing-based ( window that displays a green progress bar if all the tests passed or a red progress bar if any of the tests failed. The textual user interface ( ) displays OK if all the tests passed and failure messages if any of the tests failed. In general, and classes should define a method which employs the appropriate user interface. The tests we ve written so far have defined a using the AWT-based user interface. Discussion Jacky Wang Jacky.Wang@ca.com PMT 2001 emag@pmtsolution.net 13
PMT 2001 emag@pmtsolution.net 14 P M T R e v ie w
PMT 2001 emag@pmtsolution.net 15
PMT 2001 emag@pmtsolution.net 16
PMT 2001 emag@pmtsolution.net 17
PMT 2001 emag@pmtsolution.net 18
PMT 2001 emag@pmtsolution.net 19
PMT PMT Dictionary engineering IEEE Std 610.12-1990 The application of systematic, disciplined, quantifiable approach to structures, machines, products, systems, or processes. PMT pmt_review-subscribe@cn.egroups.com PMT pmt_review-unsubscribe@cn.egroups.com email emag@pmtsolution.net PMT http://cn.egroups.com/group/pmt_review http://www.smiling.com.cn/search/groupinfo.ecgi?group_id=17314 emag@pmtsolution.net PMT 2001 emag@pmtsolution.net 20
PMT PMT Review Co-Translation Project PMT cotrans@pmtsolution.net PMT PMT PMT PMT PMT... PMT 2001 emag@pmtsolution.net 21
cotrans@pmtsolution.net PMT cotrans@pmtsolution.net cotrans@pmtsolution.net cotrans@pmtsolution.net PMT PMT cotrans@pmtsolution.net PMT PMT PMT 1. From Craft to Science Searching for First Principles of Software Development 2. Explaining the UML 3. Managing Use-Case Details 4. A Roadmap for Software Test Engineering 5. Intelligent Test Automation 6. Using the Software CMM in Small Organizations 7. Using the Software CMM with Good Judgment 8. Why is Process Improvement So Hard 9. From Waterfall to Iterative Development -- A Challenging Transition for Project Managers 10. Extreme Lessons Learned http://cn.egroups.com/group/pmt_review http://www.smiling.com.cn/search/groupinfo.ecgi?group_id=17314 PMT 2001 emag@pmtsolution.net 22