Nowadays UML has been the de facto standard of software modeling languages, and it also brings a new challenge to software testing－How to do software testing based on UML design models. To generate test cases directly from UML activity diagrams, a formal definition of UML activity diagrams and a grey-box test method are proposed. The method first extracts each possible executing path named a test scenario from an UML activity diagram, then it gets input/output variables and relative constraints from the activity states and transitions in each test scenario to generate test cases. A test case generation tool based on this method named UMLTGF is also implemented, it can extract the information of UML activity diagrams from Rational Rose specification files and automatically generate test cases. The tool improves the process of test case generation and reduces the cost of test model creation.