diff --git a/testrunner/app/controllers/testrunner.go b/testrunner/app/controllers/testrunner.go index 5982ef7..bbf3f74 100644 --- a/testrunner/app/controllers/testrunner.go +++ b/testrunner/app/controllers/testrunner.go @@ -6,6 +6,7 @@ import ( "fmt" "html/template" "reflect" + "sort" "strings" "github.com/revel/revel" @@ -191,21 +192,40 @@ func describeSuite(testSuite interface{}) TestSuiteDesc { // errorSummary gets an error and returns its summary in human readable format. func errorSummary(err *revel.Error) (message string) { - message = fmt.Sprintf("%4sStatus: %s\n%4sIn %s", "", err.Description, "", err.Path) + expected_prefix := "(expected)" + actual_prefix := "(actual)" + errDesc := err.Description + //strip the actual/expected stuff to provide more condensed display. + if strings.Index(errDesc, expected_prefix) == 0 { + errDesc = errDesc[len(expected_prefix):len(errDesc)] + } + if strings.LastIndex(errDesc, actual_prefix) > 0 { + errDesc = errDesc[0 : len(errDesc)-len(actual_prefix)] + } - // If line of error isn't known return the message as is. - if err.Line == 0 { - return + errFile := err.Path + slashIdx := strings.LastIndex(errFile, "/") + if slashIdx > 0 { + errFile = errFile[slashIdx+1 : len(errFile)] } - // Otherwise, include info about the line number and the relevant - // source code lines. - message += fmt.Sprintf(" (around line %d): ", err.Line) - for _, line := range err.ContextSource() { - if line.IsError { - message += line.Source + message = fmt.Sprintf("%s %s#%d", errDesc, errFile, err.Line) + + /* + // If line of error isn't known return the message as is. + if err.Line == 0 { + return } - } + + // Otherwise, include info about the line number and the relevant + // source code lines. + message += fmt.Sprintf(" (around line %d): ", err.Line) + for _, line := range err.ContextSource() { + if line.IsError { + message += line.Source + } + } + */ return } @@ -234,6 +254,15 @@ func formatResponse(t testing.TestSuite) map[string]string { } } +//sortbySuiteName sorts the testsuites by name. +type sortBySuiteName []interface{} + +func (a sortBySuiteName) Len() int { return len(a) } +func (a sortBySuiteName) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +func (a sortBySuiteName) Less(i, j int) bool { + return reflect.TypeOf(a[i]).Elem().Name() < reflect.TypeOf(a[j]).Elem().Name() +} + func init() { // Every time app is restarted convert the list of available test suites // provided by the revel testing package into a format which will be used by @@ -241,6 +270,7 @@ func init() { revel.OnAppStart(func() { // Extracting info about available test suites from revel/testing package. registeredTests = map[string]int{} + sort.Sort(sortBySuiteName(testing.TestSuites)) for _, testSuite := range testing.TestSuites { testSuites = append(testSuites, describeSuite(testSuite)) } diff --git a/testrunner/app/views/TestRunner/Index.html b/testrunner/app/views/TestRunner/Index.html index 712dbc9..61f0991 100644 --- a/testrunner/app/views/TestRunner/Index.html +++ b/testrunner/app/views/TestRunner/Index.html @@ -1,110 +1,205 @@ - - Revel Test Runner - - - - - - - - - -
-
-
-

Test Runner

-

Run all of your application's tests from here.

-
- -
-
-
- -
- {{range .testSuites}} -

{{.Name}}

- - {{range .Tests}} - - - - - - {{end}} -
{{.Name}} -
- {{end}} -
- - - - + + Revel Test Runner + + + + + + + + + +
+
+

Test Runner - Run your unit tests here.

+
+ +
+
+
+
+
+ {{range .testSuites}} + {{ $testFile := .Name }} +
+
+ +  {{.Name}} +
+
+ + {{range .Tests}} + + + + + + {{end}} +
  {{ .Name }}
+
+
+ {{end}} +
+ + + +