1 package net.sourceforge.selfesteem.test;
2
3 import junit.framework.TestCase;
4 import net.sourceforge.selfesteem.TestNode;
5 import org.jdom.Element;
6
7 public class TestNodeTest extends TestCase {
8 public TestNodeTest(String s) {
9 super(s);
10 }
11
12 public void testCreation() {
13 TestNode node = new TestNode("story/test foo", true, 0.02);
14 assertEquals("story", node.getStoryName());
15 assertEquals("test foo", node.getName());
16 assertTrue(node.isPassing());
17 assertEquals(0.0, 0.02, node.getTime());
18 }
19
20 public void testPassFromXML() {
21 TestNode node = new TestNode(createElement());
22
23 assertEquals("diggable", node.getStoryName());
24 assertEquals("foo", node.getName());
25 assertTrue(node.isPassing());
26 assertEquals(0.0, 0.02, node.getTime());
27
28 assertEquals("foo", node.toString());
29 }
30
31 public void testErrorFromXML() {
32 Element error = new Element("error");
33 error.setAttribute("message", "my message");
34 error.setAttribute("type", "runtimeException");
35 error.setText("theStackTrace");
36
37 Element element = createElement();
38 element.addContent(error);
39
40 TestNode node = new TestNode(element);
41 assertTrue(!node.isPassing());
42 assertEquals("theStackTrace", node.getStackTrace());
43 assertEquals("my message", node.getErrorMessage());
44
45 assertEquals("foo - my message", node.toString());
46 }
47
48 public void testFailureFromXML() {
49 Element error = new Element("failure");
50 error.setAttribute("message", "my message");
51 error.setAttribute("type", "runtimeException");
52 error.setText("theStackTrace");
53
54 Element element = createElement();
55 element.addContent(error);
56 TestNode node = new TestNode(element);
57 assertTrue(!node.isPassing());
58 assertEquals("theStackTrace", node.getStackTrace());
59 assertEquals("my message", node.getErrorMessage());
60
61 assertEquals("foo - my message", node.toString());
62 }
63
64 private Element createElement() {
65 Element element = new Element("testcase");
66 element.setAttribute("name", "diggable/foo");
67 element.setAttribute("time", "0.145");
68 return element;
69 }
70 }
This page was automatically generated by Maven