• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.cts.tradefed.result;
17 
18 import junit.framework.TestCase;
19 
20 /**
21  * Unit tests for {@link Test}.
22  * <p/>
23  * Lets hope a TestTestTest is not needed...
24  */
25 public class TestTest extends TestCase {
26 
27     /**
28      * Test {@link Test#getFailureMessageFromStackTrace(String)} for an empty stack
29      */
testGetFailureMessageFromStackTrace_empty()30     public void testGetFailureMessageFromStackTrace_empty() {
31         final String stack = "";
32         assertEquals(stack, Test.getFailureMessageFromStackTrace(stack));
33     }
34 
35     /**
36      * Test {@link Test#getFailureMessageFromStackTrace(String)} for a one line stack
37      */
testGetFailureMessageFromStackTrace_oneLine()38     public void testGetFailureMessageFromStackTrace_oneLine() {
39         final String stack = "this is a line";
40         assertEquals(stack, Test.getFailureMessageFromStackTrace(stack));
41     }
42 
43     /**
44      * Test {@link Test#getFailureMessageFromStackTrace(String)} for a one line stack with a newline
45      * char
46      */
testGetFailureMessageFromStackTrace_oneNewLine()47     public void testGetFailureMessageFromStackTrace_oneNewLine() {
48         final String stack = "this is a line\n";
49         assertEquals(stack, Test.getFailureMessageFromStackTrace(stack));
50     }
51 
52     /**
53      * Test {@link Test#getFailureMessageFromStackTrace(String)} for a two line stack
54      */
testGetFailureMessageFromStackTrace_twoLines()55     public void testGetFailureMessageFromStackTrace_twoLines() {
56         final String stack = "this is a line\nthis is also a line";
57         assertEquals(stack, Test.getFailureMessageFromStackTrace(stack));
58     }
59 
60     /**
61      * Test {@link Test#getFailureMessageFromStackTrace(String)} for a multi line stack
62      */
testGetFailureMessageFromStackTrace_multiLines()63     public void testGetFailureMessageFromStackTrace_multiLines() {
64         final String stack = "this is a line\nthis is also a line\n oh look another line";
65         assertEquals("this is a line\nthis is also a line",
66                 Test.getFailureMessageFromStackTrace(stack));
67     }
68 }
69