CompilationUnitBuilder compilationUnitBuilder = null;
String testJavaFileName = JavaParserUtils.findTestJavaFileName(sourceCU, javaFile, testDir);
boolean testExist = FileChecker.isTestJavaClassExist(new File(testJavaFileName));
if (!testExist) {
CommandInvoker invoker = new CommandInvoker(new NewTestCommand(new NewTestReceiver(sourceCU, javaFile)));
compilationUnitBuilder = invoker.action();
} else if (testExist) {
CompilationUnit testCU = JavaParserFactory.getCompilationUnit(new File(testJavaFileName), sourceEncode);
CommandInvoker invoker = new CommandInvoker(new ExistTestCommand(new ExistTestReceiver(sourceCU, javaFile,
testCU)));
compilationUnitBuilder = invoker.action();
}
if (null != compilationUnitBuilder){
CompilationUnit testCU = compilationUnitBuilder.build();
//写入测试代码文件