testdev/ite/test/com.nokia.testfw.core.test/src/com/nokia/testfw/core/model/TestCaseTest.java
changeset 1 96906a986c3b
equal deleted inserted replaced
0:f1112f777ce9 1:96906a986c3b
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Symbian Foundation License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 package com.nokia.testfw.core.model;
       
    18 
       
    19 import com.nokia.testfw.core.model.TestResult.TestStatus;
       
    20 
       
    21 import junit.framework.TestCase;
       
    22 
       
    23 /**
       
    24  * @author xiaoma
       
    25  *
       
    26  */
       
    27 public class TestCaseTest extends TestCase {
       
    28     com.nokia.testfw.core.model.TestCase testCase;
       
    29     
       
    30     protected void setUp() {
       
    31 		testCase = new com.nokia.testfw.core.model.TestCase("Test1");
       
    32     }
       
    33 	
       
    34 	protected void tearDown() {
       
    35 		testCase = null;
       
    36 	}
       
    37 	
       
    38 	public void testProperty() {
       
    39 		testCase.addProperty("key1", "value1");
       
    40 		testCase.addProperty("key2", "value2");
       
    41 		assertEquals("value1", testCase.getProperty("key1"));
       
    42 		assertEquals("value2", testCase.getProperties().get("key2"));
       
    43 	}
       
    44 	
       
    45 	public void testAttributes() {
       
    46 		assertEquals("Test1", testCase.getIdentifier());
       
    47 		testCase.setIdentifier("Test2");
       
    48 		assertEquals("Test2", testCase.getIdentifier());
       
    49 		
       
    50 		String version="v0.1";
       
    51 		testCase.setVersion(version);
       
    52 		assertEquals(version, testCase.getVersion());
       
    53 		
       
    54 		String desc="model test caes";
       
    55 		testCase.setDescription(desc);
       
    56 		assertEquals(desc, testCase.getDescription());
       
    57 		
       
    58 		String spec="REQ001";
       
    59 		testCase.setSpecRef(spec);
       
    60 		assertEquals(spec, testCase.getSpecRef());
       
    61 		
       
    62 		String purpose = "reason1";
       
    63 		testCase.setPurpose(purpose);
       
    64 		assertEquals(purpose, testCase.getPurpose());
       
    65 		testCase.toString();
       
    66 		
       
    67 	}
       
    68 	
       
    69 	public void testEqual() {
       
    70 		testCase.setIdentifier("case1");
       
    71 		com.nokia.testfw.core.model.TestCase case1 = new com.nokia.testfw.core.model.TestCase("case1");
       
    72 		com.nokia.testfw.core.model.TestCase case2 = new com.nokia.testfw.core.model.TestCase("case2");
       
    73 		assertTrue(testCase.equals(case1));
       
    74 		assertFalse(testCase.equals(case2));
       
    75 	}
       
    76 	
       
    77 	public void testStartStop() {
       
    78 		//test success case
       
    79 		com.nokia.testfw.core.model.TestSuite suite = new com.nokia.testfw.core.model.TestSuite();
       
    80 		testCase.setSuite(suite);
       
    81 		testCase.getSuite();
       
    82 		testCase.start();
       
    83 		testCase.stop(TestStatus.SUCCESS, null);
       
    84 		
       
    85 		//check test result
       
    86 		TestResult result = testCase.getResult();
       
    87 		result.toString();
       
    88 		assertTrue(result.getStartTime() != 0);
       
    89 		assertTrue(result.getEndTime() != 0);
       
    90 		assertTrue(result.status == TestStatus.SUCCESS);
       
    91 	
       
    92 		//test failure case
       
    93 		com.nokia.testfw.core.model.TestCase case2 = new com.nokia.testfw.core.model.TestCase("case2");
       
    94 		case2.setSuite(suite);
       
    95 		case2.start();
       
    96 		case2.stop(TestStatus.FAILURE, "assert error");
       
    97 		//check test result
       
    98 		result = case2.getResult();
       
    99 		assertTrue(result.getStartTime() != 0);
       
   100 		assertTrue(result.getEndTime() != 0);
       
   101 		assertTrue(result.status == TestStatus.FAILURE);
       
   102 	    assertNotNull(result.getFailure());
       
   103 		
       
   104 	}
       
   105 	
       
   106     
       
   107 }