1. Miki Tebeka
  2. go2xunit

Commits

Marcelo Glezer  committed 8b45c0c Merge

merge to master

  • Participants
  • Parent commits f4d25a4, 5852ce9
  • Branches default

Comments (0)

Files changed (3)

File go2xunit.go

View file
  • Ignore whitespace
 
 		switch err {
 		case io.EOF:
-			// nextTest()
-			// nextSuite()
 			if suite != nil || test != nil {
 				// if suite or test in progress EOF is an unexpected EOF
 				return nil, fmt.Errorf("Unexpected EOF")

File go2xunit_test.go

View file
  • Ignore whitespace
 	}
 }
 
-func loadTests(filename string, t *testing.T) []*Test {
+func loadTests(filename string, t *testing.T) []*Suite {
 	file, err := os.Open(filename)
 	if err != nil {
 		t.Fatalf("can't open %s - %s", filename, err)
 	}
 
-	tests, err := parseOutput(file)
+	suites, err := parseOutput(file)
 	if err != nil {
 		t.Fatalf("error parsing - %s", err)
 	}
 
-	return tests
+	return suites
 }
 
 func Test_parseOutput(t *testing.T) {
-	tests := loadTests("gotest.out", t)
+	suites := loadTests("gotest.out", t)
+	if len(suites) != 2 {
+		t.Fatalf("got %d suites instead of 2", len(suites))
+	}
+	if suites[0].Name != "_/home/miki/Projects/goroot/src/xunit" {
+		t.Fatalf("bad Suite name %s, expected _/home/miki/Projects/goroot/src/xunit", suites[0].Name)
+	}
+	if suites[1].Name != "_/home/miki/Projects/goroot/src/anotherTest" {
+		t.Fatalf("bad Suite name %s, expected _/home/miki/Projects/goroot/src/anotherTest", suites[1].Name)
+	}
+
+	tests := suites[0].Tests
 	if len(tests) != 4 {
 		t.Fatalf("got %d tests instead of 4", len(tests))
 	}
 	if len(test.Message) != 0 {
 		t.Fatalf("bad message (should be empty): %s", test.Message)
 	}
+	tests = suites[1].Tests
+	if len(tests) != 1 {
+		t.Fatalf("got %d tests instead of 1", len(tests))
+	}
+
+	if numFailures(tests) != 0 {
+		t.Fatalf("wrong number of failed %d, should be 0", numFailures(tests))
+	}
+
+	test = tests[0]
+	if test.Name != "TestAdd" {
+		t.Fatalf("bad test name %s, expected TestAdd", test.Name)
+	}
+
+	if test.Time != "0.00" {
+		t.Fatalf("bad test time %s, expected 0.00", test.Time)
+	}
+
+	if len(test.Message) != 0 {
+		t.Fatalf("bad message (should be empty): %s", test.Message)
+	}
 }
 
 func Test_parseOutputBad(t *testing.T) {
-	tests := loadTests("go2xunit.go", t)
-	if len(tests) != 0 {
-		t.Fatalf("managed to find tests in junk")
+	suites := loadTests("go2xunit.go", t)
+	if len(suites) != 0 {
+		t.Fatalf("managed to find suites in junk")
 	}
 }

File gotest.out

View file
  • Ignore whitespace
 FAIL
 exit status 1
 FAIL	_/home/miki/Projects/goroot/src/xunit	0.004s
+=== RUN TestAdd
+--- PASS: TestAdd (0.00 seconds)
+ok  	_/home/miki/Projects/goroot/src/anotherTest	0.000s