示例#1
0
 @Override
 public void startTest(Test test) {
   try {
     if (test instanceof TestCase) {
       TestCase testCase = TestCase.class.cast(test);
       if (currentTestCase == null || testCase.getClass() != currentTestCase.getClass()) {
         // If this is the first test or different test case class is passed,
         // close last <testsuite> and start new <testsuite>.
         if (currentTestCase != null) {
           // <testsuite> has been started already so close it.
           serializer.endTag(NS_DEFAULT, TAG_TESTSUITE);
         }
         serializer.startTag(NS_DEFAULT, TAG_TESTSUITE);
         serializer.attribute(NS_DEFAULT, ATTR_NAME, testCase.getClass().getName());
       }
       serializer.startTag(NS_DEFAULT, TAG_TESTCASE);
       serializer.attribute(NS_DEFAULT, ATTR_NAME, testCase.getName());
       currentTestCase = testCase;
       testCaseStartTime = System.currentTimeMillis();
       isTimeAppended = false;
     } else {
       MozcLog.e("Unextected type; " + test.getClass().getCanonicalName());
     }
   } catch (IOException e) {
     MozcLog.e(e.getMessage(), e);
   }
 }
示例#2
0
 @Override
 public void endTest(Test test) {
   try {
     if (test != currentTestCase) {
       MozcLog.e("Unexpected test " + test + "; Expected one is " + currentTestCase);
     } else if (test instanceof TestCase) {
       maybeAddTimeAttribute();
       serializer.endTag(NS_DEFAULT, TAG_TESTCASE);
     } else {
       MozcLog.e("Unextected type; " + test.getClass().getCanonicalName());
     }
   } catch (IOException e) {
     MozcLog.e(e.getMessage(), e);
   }
 }
示例#3
0
 /**
  * Note : {@link #close()} must be called from the caller side.
  *
  * <p>The method will close the XML document by close tags.
  */
 public MozcTestListener(Writer writer, String suitesName) {
   serializer = Xml.newSerializer();
   try {
     serializer.setOutput(writer);
     serializer.startDocument("UTF-8", true);
     serializer.startTag(NS_DEFAULT, TAG_TESTSUITES);
     serializer.attribute(NS_DEFAULT, ATTR_NAME, suitesName);
   } catch (IOException e) {
     MozcLog.e(e.getMessage(), e);
   }
 }
示例#4
0
 // Reaches here because the test fails.
 // Note that endTest method will be also invoke soon.
 private void addProblem(String namespace, String tag, Throwable throwable) {
   try {
     maybeAddTimeAttribute();
     serializer.startTag(namespace, tag);
     if (throwable.getMessage() != null) {
       serializer.attribute(namespace, ATTR_MESSAGE, throwable.getMessage());
     }
     serializer.attribute(namespace, ATTR_TYPE, throwable.getClass().getName());
     StringWriter stringWriter = new StringWriter();
     throwable.printStackTrace(new PrintWriter(stringWriter));
     serializer.text(stringWriter.toString());
     serializer.endTag(namespace, tag);
   } catch (IOException e) {
     MozcLog.e(e.getMessage(), e);
   }
 }