当前位置: 首页>>代码示例>>Java>>正文


Java TestUtils.write方法代码示例

本文整理汇总了Java中osmo.common.TestUtils.write方法的典型用法代码示例。如果您正苦于以下问题:Java TestUtils.write方法的具体用法?Java TestUtils.write怎么用?Java TestUtils.write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在osmo.common.TestUtils的用法示例。


在下文中一共展示了TestUtils.write方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import osmo.common.TestUtils; //导入方法依赖的package包/类
public static void main(String[] args) {
  long seed = Long.parseLong(args[0]);
  OSMOConfiguration oc = new OSMOConfiguration();
  oc.setFactory(new CalendarFactory());
  EndCondition ec1 = new LengthProbability(1, 0.5);
  EndCondition ec2 = new LengthProbability(10, 0.2);
  EndCondition ec3 = new LengthProbability(50, 0.5);
  WeightedEndConditionSet set = new WeightedEndConditionSet(10, ec1, 100, ec2);
  set.addEndCondition(20, ec3);
  oc.setTestEndCondition(set);
  ScoreConfiguration sc = new ScoreConfiguration();
  MultiGreedy greedy = new MultiGreedy(oc, sc, seed);
  greedy.setTimeout(10);
  List<TestCase> tests = greedy.search();
  int i = 1;
  for (TestCase test : tests) {
    TestUtils.write((String)test.getAttribute("script"), "calendar-example/test"+i+".html");
    i++;
  }
  HTMLCoverageReporter html = new HTMLCoverageReporter(greedy.getFinalCoverage(), tests, greedy.getFsm());
  String report = html.getTraceabilityMatrix();
  TestUtils.write(report, "calendar-example/coverage.html");
}
 
开发者ID:mukatee,项目名称:osmo,代码行数:24,代码来源:Main.java

示例2: createScoreReport

import osmo.common.TestUtils; //导入方法依赖的package包/类
/**
 * Creates a report for exploration/generation.
 * Prints information such as covered elements, achieved score, used generation parameters.
 */
private void createScoreReport() {
  boolean printAll = config.isPrintAll();
  Map<String, Collection<String>> possibleValues = algorithm.getPossibleValues();
  Collection<String> possibleStepPairs = algorithm.getPossibleStepPairs();
  Map<String, Collection<String>> possibleStatePairs = algorithm.getPossibleStatePairs();
  Map<String, Collection<String>> possibleStates = algorithm.getPossibleStates();
  List<TestCase> allTests = osmo.getSuite().getAllTestCases();
  TestCoverage tc = new TestCoverage(allTests);
  ScoreCalculator sc = new ScoreCalculator(config);
  System.out.println("Generated " + allTests.size() + " tests. Achieved score " + sc.calculateScore(tc));

  CSVCoverageReport report = new CSVCoverageReport(sc);
  String summary = "summary\n";
  summary += tc.coverageString(osmo.getFsm(), possibleStepPairs, possibleValues, possibleStates, possibleStatePairs, printAll);
  System.out.println(summary);
  report.process(allTests);
  String totalCsv = report.report();
  totalCsv += summary + "\n";
  TestUtils.write(totalCsv, createFullReportPath());
}
 
开发者ID:mukatee,项目名称:osmo,代码行数:25,代码来源:OSMOExplorer.java

示例3: writeFinalReport

import osmo.common.TestUtils; //导入方法依赖的package包/类
/**
 * Write the final report for the overall optimized test set.
 * Goes into "osmo-output/greedy-<seed>/final-scores.csv" file.
 * 
 * @param cases The final set of generated tests.
 * @param seed The seed used in configuring all the optimizers. Shown in report.
 */
private void writeFinalReport(List<TestCase> cases, long seed) {
  String summary = "summary\n";
  summary += "tests: "+cases.size()+"\n";
  
  CSVCoverageReport report = new CSVCoverageReport(calculator);
  report.process(cases);

  finalCoverage = new TestCoverage(cases);
  summary += finalCoverage.coverageString(fsm, possiblePairs, null, null, null, false);

  String totalCsv = report.report();
  totalCsv += summary + "\n";
  String filename = createFinalReportPath();
  TestUtils.write(totalCsv, filename);
}
 
开发者ID:mukatee,项目名称:osmo,代码行数:23,代码来源:MultiGreedy.java

示例4: writeReports

import osmo.common.TestUtils; //导入方法依赖的package包/类
/**
 * Write the d reports for found steps and invariants.
 *
 * @param allSteps All steps in test model, used in test or not.
 * @param state End state for reduction to report.
 */
private void writeReports(List<String> allSteps, ReducerState state) {
  //first we find all invariants and write the basic report on those
  Analyzer analyzer = new Analyzer(allSteps, state);
  analyzer.analyze();
  analyzer.writeReport("reducer-final");

  //then we write the traces for best tests, limiting to max of 100 traces
  List<TestCase> tests = state.getTests();
  List<TestCase> traced = new ArrayList<>();
  int i = 1;
  for (TestCase test : tests) {
    i++;
    //only print max of 100 traces
    if (i > 100) break;
    traced.add(test);
  }
  String filename = analyzer.getPath() + "final-tests";
  OSMOTester.writeTrace(filename, traced, config.getSeed(), osmoConfig);
  String filename2 = analyzer.getPath() + "final-fuzz-times.csv";
  TestUtils.write(state.getFinalFuzzTimes(), filename2);
}
 
开发者ID:mukatee,项目名称:osmo,代码行数:28,代码来源:Reducer.java

示例5: greedy

import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test
public void greedy() {
  OSMOConfiguration oc = new OSMOConfiguration();
  oc.setTestEndCondition(new LengthProbability(10, 20, 0.2d));
  oc.setFactory(models -> models.add(new VendingMachine()));
  ScoreConfiguration config = new ScoreConfiguration();
  config.setLengthWeight(0);
  MultiGreedy mg = new MultiGreedy(oc, config, 111, 1);
  mg.setPopulationSize(500);
  mg.setMaxIterations(5);
  List<TestCase> tests = mg.search();
  int i = 1;
  for (TestCase test : tests) {
    TestUtils.write(test.getAttribute("script").toString(), "example/tests/"+test.getName()+".txt");
    i++;
  }
  TestCoverage coverage = mg.getFinalCoverage();
  HTMLCoverageReporter html = new HTMLCoverageReporter(coverage, tests, mg.getFsm());
  String matrix = html.getTraceabilityMatrix();
  TestUtils.write(matrix, "example/example_report.html");
}
 
开发者ID:mukatee,项目名称:osmo,代码行数:22,代码来源:Examples.java

示例6: main

import osmo.common.TestUtils; //导入方法依赖的package包/类
/**
 * This is used to execute the calendar example with an offline scripter.
 *
 * @param args command line arguments, ignored.
 */
public static void main(String[] args) throws Exception {
  OSMOTester osmo = new OSMOTester();
  OSMOConfiguration config = new OSMOConfiguration();
  osmo.setConfig(config);
  config.setTestEndCondition(new Length(5));
  config.setSuiteEndCondition(new Length(5));
  ModelState state = new ModelState();
  state.setUserCount(3);
  OfflineScripter scripter = new OfflineScripter(state, "tests.html");
  SingleInstanceModelFactory factory = new SingleInstanceModelFactory();
  config.setFactory(factory);
  factory.add(state);
  factory.add(new CalendarMeetingModel(state, scripter));
  factory.add(new CalendarOracleModel(state, scripter));
  factory.add(new CalendarTaskModel(state, scripter));
  factory.add(new CalendarOverlappingModel(state, scripter));
  factory.add(new CalendarParticipantModel(state, scripter));
  factory.add(new CalendarErrorHandlingModel(state, scripter));
  osmo.generate(55);
  scripter.write();
  TestSuite suite = osmo.getSuite();
  FSM fsm = osmo.getFsm();
  HTMLCoverageReporter html = new HTMLCoverageReporter(suite.getCoverage(), suite.getAllTestCases(), fsm);
  String report = html.getTraceabilityMatrix();
  TestUtils.write(report, "coverage.html");
}
 
开发者ID:mukatee,项目名称:osmo,代码行数:32,代码来源:OfflineMain.java

示例7: main

import osmo.common.TestUtils; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
  OSMOTester osmo = new OSMOTester();
  SingleInstanceModelFactory factory = new SingleInstanceModelFactory();
  osmo.setModelFactory(factory);
  factory.add(new CalculatorModel());
  osmo.setSuiteEndCondition(new Length(10));
  osmo.setTestEndCondition(new Length(5));
  osmo.generate(2342);
  TestSuite suite = osmo.getSuite();
  HTMLCoverageReporter reporter = new HTMLCoverageReporter(suite.getCoverage(), suite.getAllTestCases(), osmo.getFsm());
  String matrix = reporter.getTraceabilityMatrix();
  String file = "calculator-matrix.html";
  TestUtils.write(matrix, file);
}
 
开发者ID:mukatee,项目名称:osmo,代码行数:15,代码来源:CalculatorMatrix.java

示例8: writeCoverageReport

import osmo.common.TestUtils; //导入方法依赖的package包/类
private static void writeCoverageReport(String filename, List<TestCase> tests) {
  String summary = "summary\n";
  CSVCoverageReport report = new CSVCoverageReport(new ScoreCalculator(new ScoreConfiguration()));
  report.process(tests);

  String totalCsv = report.report();
  totalCsv += summary + "\n";
  //we only write the coverage report if
  TestUtils.write(totalCsv, filename + ".csv");
}
 
开发者ID:mukatee,项目名称:osmo,代码行数:11,代码来源:OSMOTester.java

示例9: createJenkinsReport

import osmo.common.TestUtils; //导入方法依赖的package包/类
private static void createJenkinsReport(String filename, List<TestCase> tests, long seed, OSMOConfiguration config) {
  JenkinsReportGenerator jenkins = new JenkinsReportGenerator(null, false);
  jenkins.init(seed, null, config);
  jenkins.suiteStarted(null);
  for (TestCase test : tests) {
    jenkins.testEnded(test);
  }
  jenkins.suiteEnded(null);
  String report = jenkins.generateTestReport();
  TestUtils.write(report, filename + ".xml");
}
 
开发者ID:mukatee,项目名称:osmo,代码行数:12,代码来源:OSMOTester.java

示例10: write

import osmo.common.TestUtils; //导入方法依赖的package包/类
public void write(TestCase test) {
  StringBuilder output = new StringBuilder();
  output.append("#OSMO Tester test case. Format v0.1.\n");
  output.append("seed:").append(test.getSeed()).append("\n");
  List<String> stepNames = test.getAllStepNames();
  for (String step : stepNames) {
    output.append(step).append("\n");
  }
  TestUtils.write(output.toString(), outputDir+"/"+test.getName()+".tc");
}
 
开发者ID:mukatee,项目名称:osmo,代码行数:11,代码来源:TestWriter.java

示例11: writeReport

import osmo.common.TestUtils; //导入方法依赖的package包/类
private void writeReport(CSVCoverageReport report, TestCoverage tc, int resultSize, int generationCount) {
  String summary = "summary\n";
  //we do not have the set of possible states or state pairs as those would require executing the "states" which greedy does not do..
  summary += tc.coverageString(fsm, possiblePairs, null, null, null, false);

  String totalCsv = report.report();
  totalCsv += summary + "\n";
  TestUtils.write(totalCsv, createReportPath());
  long end = System.currentTimeMillis();
  long diff = end - start;
  log.i("GreedyOptimizer " + id + " generated " + generationCount + " tests.");
  log.i("Resulting suite has " + resultSize + " tests. Generation time " + diff + " millis");
}
 
开发者ID:mukatee,项目名称:osmo,代码行数:14,代码来源:GreedyOptimizer.java

示例12: htmlMatrix

import osmo.common.TestUtils; //导入方法依赖的package包/类
@Test
public void htmlMatrix() throws Exception {
  String expected = getResource(MatrixTests.class, "expected-matrix.txt");
  HTMLCoverageReporter html = new HTMLCoverageReporter(suite.getCoverage(), suite.getAllTestCases(), fsm);
  String actual = html.getTraceabilityMatrix();
  TestUtils.write(actual, "test-matrix.html");
  expected = unifyLineSeparators(expected, "\n");
  actual = unifyLineSeparators(actual, "\n");
  assertEquals("Generated HTML coverage matrix", expected, actual);
}
 
开发者ID:mukatee,项目名称:osmo,代码行数:11,代码来源:MatrixTests.java

示例13: write

import osmo.common.TestUtils; //导入方法依赖的package包/类
public void write(List<TestCase> tests, String filename) throws Exception {
  String report = createReport(tests);
  TestUtils.write(report, filename);
}
 
开发者ID:mukatee,项目名称:osmo,代码行数:5,代码来源:TraceReportWriter.java

示例14: writeReport

import osmo.common.TestUtils; //导入方法依赖的package包/类
/**
 * Writes a report of current found invariants into a file on disk. Uses velocity templates.
 * 
 * @param name Name for the file. Path is determined with getPath().
 */
public void writeReport(String name) {
  TestUtils.write(createReport(), getPath() + name + ".txt");
}
 
开发者ID:mukatee,项目名称:osmo,代码行数:9,代码来源:Analyzer.java


注:本文中的osmo.common.TestUtils.write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。