package bluej.parser;

import java.io.Reader;
import java.util.*;





| @author Andrew | | To change the template for this generated type comment go to | Window - Preferences - Java - Code Generation - Code and Comments | public class UnitTestAnalyzer { UnitTestParser utp;
| Analyse unit test source code. | public UnitTestAnalyzer(Reader r) { utp = new UnitTestParser(r); }
| Extract from the unit testing source the list of source spans | for the fields declared in the unit test class. | | Ie | | Class FooBar {} * private int a = 10; | java.util.HashMap h,i,j = null; | public String aString; | } | gives us a list with SourceSpan objects encompassing | p in private to ; | j in java to ; | p in public to ; | | The list will be ordered in the order that the fields appear in the src. | public List getFieldSpans() { return utp.getFieldSpans(); }
| Extract from the unit testing source | the opening and closing bracket locations for the method 'methodName'. | We select only methods that do not have any parameters (all unit test | methods take no arguments). | ie | | Class FooBar {} * public void setUp() {} * // do something | i++; | } | } | gives us a SourceSpan object from the second "{} to the first "}" |*/ public SourceSpan getMethodBlockSpan(String methodName) { return utp.getMethodBlockSpan(methodName); } /** * Extract from the unit test source a source location where | we should insert declarations of fields (that will become | the classes fixtures). | | @return | public SourceLocation getFixtureInsertLocation() { return utp.getFixtureInsertLocation(); }
| Extract from the unit test source a source location where | we can insert new methods. | | @return | public SourceLocation getNewMethodInsertLocation() { return utp.getNewMethodInsertLocation(); } }
top, use, map, class UnitTestAnalyzer

.   UnitTestAnalyzer
.   getFieldSpans
.   getFixtureInsertLocation
.   getNewMethodInsertLocation




43 neLoCode + 32 LoComm