Package org.junithelper.core.generator.impl

Examples of org.junithelper.core.generator.impl.DefaultTestCaseGenerator


    // confirm input from stdin
    if (confirmToExecute() > 0) {
      return;
    }
    FileReader fileReader = new CommonsIOFileReader();
    TestCaseGenerator testCaseGenerator = new DefaultTestCaseGenerator(config);
    for (File javaFile : javaFiles) {
      File testFile = null;
      String currentTestCaseSourceCode = null;
      try {
        testFile = new File(javaFile.getAbsolutePath()
            .replaceAll("\\\\", "/")
            .replaceFirst(getDirectoryPathOfProductSourceCode(config),
                getDirectoryPathOfTestSourceCode(config))
            .replaceFirst("\\.java", "Test.java"));
        currentTestCaseSourceCode = fileReader.readAsString(testFile);
      } catch (Exception e) {
      }
      testCaseGenerator.initialize(fileReader.readAsString(javaFile));
      String testCodeString = null;
      if (currentTestCaseSourceCode != null) {
        testCodeString = testCaseGenerator.getTestCaseSourceCodeWithLackingTestMethod(
            currentTestCaseSourceCode);
        if (!testCodeString.equals(currentTestCaseSourceCode)) {
          Stdout.p("  Modified: " + testFile.getAbsolutePath());
          new CommonsIOFileWriter(testFile).writeText(testCodeString);
        }
      } else {
        testCodeString = testCaseGenerator.getNewTestCaseSourceCode();
        Stdout.p("  Created: " + testFile.getAbsolutePath());
        new CommonsIOFileWriter(testFile).writeText(testCodeString);
      }
    }
  }
View Full Code Here


    }
    // confirm input from stdin
    if (confirmToExecute() > 0) {
      return;
    }
    TestCaseGenerator testCaseGenerator = new DefaultTestCaseGenerator(config);
    FileReader fileReader = new CommonsIOFileReader();
    for (File javaFile : javaFiles) {
      File testFile = null;
      String currentTestCaseSourceCode = null;
      try {
        testFile = new File(javaFile.getAbsolutePath().replaceAll("\\\\", "/")
            .replaceFirst(getDirectoryPathOfProductSourceCode(config),
                getDirectoryPathOfTestSourceCode(config))
            .replaceFirst("\\.java", "Test.java"));
        currentTestCaseSourceCode = fileReader.readAsString(testFile);
      } catch (Exception e) {
      }
      testCaseGenerator.initialize(fileReader.readAsString(javaFile));
      String testCodeString = null;
      if (currentTestCaseSourceCode != null) {
        testCodeString = testCaseGenerator.getUnifiedVersionTestCaseSourceCode(
            testCaseGenerator.getTestCaseSourceCodeWithLackingTestMethod(currentTestCaseSourceCode),
            JUnitVersion.version4);
      } else {
        testCodeString = testCaseGenerator.getNewTestCaseSourceCode();
      }
      new CommonsIOFileWriter(testFile).writeText(testCodeString);
      Stdout.p("  Forced JUnit 4.x: " + testFile.getAbsolutePath());
    }
  }
View Full Code Here

    }
    // confirm input from stdin
    if (confirmToExecute() > 0) {
      return;
    }
    TestCaseGenerator testCaseGenerator = new DefaultTestCaseGenerator(config);
    FileReader fileReader = new CommonsIOFileReader();
    for (File javaFile : javaFiles) {
      File testFile = null;
      String currentTestCaseSourceCode = null;
      try {
        testFile = new File(javaFile.getAbsolutePath().replaceAll("\\\\", "/")
            .replaceFirst(getDirectoryPathOfProductSourceCode(config),
                getDirectoryPathOfTestSourceCode(config))
            .replaceFirst("\\.java", "Test.java"));
        currentTestCaseSourceCode = fileReader.readAsString(testFile);
      } catch (Exception e) {
      }
      testCaseGenerator.initialize(fileReader.readAsString(javaFile));
      String testCodeString = null;
      if (currentTestCaseSourceCode != null) {
        testCodeString = testCaseGenerator.getUnifiedVersionTestCaseSourceCode(
            testCaseGenerator.getTestCaseSourceCodeWithLackingTestMethod(currentTestCaseSourceCode),
            JUnitVersion.version3);
      } else {
        testCodeString = testCaseGenerator.getNewTestCaseSourceCode();
      }
      new CommonsIOFileWriter(testFile).writeText(testCodeString);
      Stdout.p("  Forced JUnit 3.x: " + testFile.getAbsolutePath());
    }
  }
View Full Code Here

    }
    // confirm input from stdin
    if (confirmToExecute() > 0) {
      return;
    }
    TestCaseGenerator testCaseGenerator = new DefaultTestCaseGenerator(config);
    FileReader fileReader = new CommonsIOFileReader();
    for (File javaFile : javaFiles) {
      File testFile = null;
      String currentTestCaseSourceCode = null;
      try {
        testFile = new File(javaFile.getAbsolutePath().replaceAll("\\\\", "/")
            .replaceFirst(getDirectoryPathOfProductSourceCode(config),
                getDirectoryPathOfTestSourceCode(config))
            .replaceFirst("\\.java", "Test.java"));
        currentTestCaseSourceCode = fileReader.readAsString(testFile);
      } catch (Exception e) {
      }
      testCaseGenerator.initialize(fileReader.readAsString(javaFile));
      String testCodeString = null;
      if (currentTestCaseSourceCode != null) {
        testCodeString = testCaseGenerator.getUnifiedVersionTestCaseSourceCode(
            testCaseGenerator.getTestCaseSourceCodeWithLackingTestMethod(currentTestCaseSourceCode),
            JUnitVersion.version4);
      } else {
        testCodeString = testCaseGenerator.getNewTestCaseSourceCode();
      }
      new CommonsIOFileWriter(testFile).writeText(testCodeString);
      Stdout.p("  Forced JUnit 4.x: " + testFile.getAbsolutePath());
    }
  }
View Full Code Here

    // confirm input from stdin
    if (confirmToExecute() > 0) {
      return;
    }
    FileReader fileReader = new CommonsIOFileReader();
    TestCaseGenerator testCaseGenerator = new DefaultTestCaseGenerator(config);
    for (File javaFile : javaFiles) {
      if (isNeedToExclude(javaFile)) {
        continue;
      }
      File testFile = null;
      String currentTestCaseSourceCode = null;
      try {
        testFile = new File(javaFile
            .getAbsolutePath()
            .replaceAll("\\\\", "/")
            .replaceFirst(getDirectoryPathOfProductSourceCode(config),
                getDirectoryPathOfTestSourceCode(config)).replaceFirst("\\.java", "Test.java"));
        currentTestCaseSourceCode = fileReader.readAsString(testFile);
      } catch (Exception e) {
      }
      testCaseGenerator.initialize(fileReader.readAsString(javaFile));
      String testCodeString = null;
      if (currentTestCaseSourceCode != null) {
        testCodeString = testCaseGenerator
            .getTestCaseSourceCodeWithLackingTestMethod(currentTestCaseSourceCode);
        if (!testCodeString.equals(currentTestCaseSourceCode)) {
          Stdout.p("  Modified: " + testFile.getAbsolutePath());
          new CommonsIOFileWriter(testFile).writeText(testCodeString);
        }
      } else {
        testCodeString = testCaseGenerator.getNewTestCaseSourceCode();
        Stdout.p("  Created: " + testFile.getAbsolutePath());
        new CommonsIOFileWriter(testFile).writeText(testCodeString);
      }
    }
  }
View Full Code Here

    }
    // confirm input from stdin
    if (confirmToExecute() > 0) {
      return;
    }
    TestCaseGenerator testCaseGenerator = new DefaultTestCaseGenerator(config);
    FileReader fileReader = new CommonsIOFileReader();
    for (File javaFile : javaFiles) {
      File testFile = null;
      String currentTestCaseSourceCode = null;
      try {
        testFile = new File(javaFile.getAbsolutePath().replaceAll("\\\\", "/")
            .replaceFirst(getDirectoryPathOfProductSourceCode(config),
                getDirectoryPathOfTestSourceCode(config))
            .replaceFirst("\\.java", "Test.java"));
        currentTestCaseSourceCode = fileReader.readAsString(testFile);
      } catch (Exception e) {
      }
      testCaseGenerator.initialize(fileReader.readAsString(javaFile));
      String testCodeString = null;
      if (currentTestCaseSourceCode != null) {
        testCodeString = testCaseGenerator.getUnifiedVersionTestCaseSourceCode(
            testCaseGenerator.getTestCaseSourceCodeWithLackingTestMethod(currentTestCaseSourceCode),
            JUnitVersion.version3);
      } else {
        testCodeString = testCaseGenerator.getNewTestCaseSourceCode();
      }
      new CommonsIOFileWriter(testFile).writeText(testCodeString);
      Stdout.p("  Forced JUnit 3.x: " + testFile.getAbsolutePath());
    }
  }
View Full Code Here

    // confirm input from stdin
    if (confirmToExecute() > 0) {
      return;
    }
    FileReader fileReader = new CommonsIOFileReader();
    TestCaseGenerator testCaseGenerator = new DefaultTestCaseGenerator(config);
    for (File javaFile : javaFiles) {
      if (isNeedToExclude(javaFile)) {
        continue;
      }
      File testFile = null;
      String currentTestCaseSourceCode = null;
      try {
        testFile = new File(javaFile
            .getAbsolutePath()
            .replaceAll("\\\\", "/")
            .replaceFirst(getDirectoryPathOfProductSourceCode(config),
                getDirectoryPathOfTestSourceCode(config)).replaceFirst("\\.java", "Test.java"));
        currentTestCaseSourceCode = fileReader.readAsString(testFile);
      } catch (Exception e) {
      }
      testCaseGenerator.initialize(fileReader.readAsString(javaFile));
      String testCodeString = null;
      if (currentTestCaseSourceCode != null) {
        testCodeString = testCaseGenerator
            .getTestCaseSourceCodeWithLackingTestMethod(currentTestCaseSourceCode);
        if (!testCodeString.equals(currentTestCaseSourceCode)) {
          Stdout.p("  Modified: " + testFile.getAbsolutePath());
          new CommonsIOFileWriter(testFile).writeText(testCodeString);
        }
      } else {
        testCodeString = testCaseGenerator.getNewTestCaseSourceCode();
        Stdout.p("  Created: " + testFile.getAbsolutePath());
        new CommonsIOFileWriter(testFile).writeText(testCodeString);
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.junithelper.core.generator.impl.DefaultTestCaseGenerator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.