junit

package
v0.0.0-...-d4285bb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2014 License: BSD-2-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package JUnit is the JUnit Java testing framework's implementation of an Impendulo tool. See http://junit.org/ for more information.

Index

Constants

View Source
const (
	NAME = "JUnit"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Failure

type Failure struct {
	Message string `xml:"message,attr"`
	Type    string `xml:"type,attr"`
	Value   string `xml:",innerxml"`
}

Failure gives details as to why a test case failed.

func (*Failure) String

func (this *Failure) String() string

String

type Report

type Report struct {
	Id bson.ObjectId
	//Errors is the number of runtime exceptions
	//which occurred when running the test cases.
	Errors int `xml:"errors,attr"`
	//Failures is the number of test cases which produced
	//an invalid result.
	Failures int     `xml:"failures,attr"`
	Name     string  `xml:"name,attr"`
	Tests    int     `xml:"tests,attr"`
	Time     float64 `xml:"time,attr"`
	//Results is all the failed testcases.
	Results TestCases `xml:"testcase"`
}

Report is created from XML output by a Ant JUnit task.

func NewReport

func NewReport(id bson.ObjectId, data []byte) (res *Report, err error)

NewReport

func (*Report) GetResults

func (this *Report) GetResults(num int) TestCases

GetResults

func (*Report) String

func (this *Report) String() string

String

func (*Report) Success

func (this *Report) Success() bool

Success

type Result

type Result struct {
	Id       bson.ObjectId `bson:"_id"`
	FileId   bson.ObjectId `bson:"fileid"`
	TestId   bson.ObjectId `bson:"testid"`
	TestName string        `bson:"name"`
	Report   *Report       `bson:"report"`
	GridFS   bool          `bson:"gridfs"`
	Type     string        `bson:"type"`
}

func NewResult

func NewResult(fileId, testId bson.ObjectId, name string, data []byte) (*Result, error)

NewResult creates a new junit.Result from provided XML data.

func (*Result) ChartVals

func (r *Result) ChartVals() []*result.ChartVal

ChartVals

func (*Result) GetFileId

func (r *Result) GetFileId() bson.ObjectId

GetFileId

func (*Result) GetId

func (r *Result) GetId() bson.ObjectId

GetId

func (*Result) GetName

func (r *Result) GetName() string

GetName

func (*Result) GetTestId

func (r *Result) GetTestId() bson.ObjectId

func (*Result) GetType

func (r *Result) GetType() string

func (*Result) OnGridFS

func (r *Result) OnGridFS() bool

OnGridFS

func (*Result) Reporter

func (r *Result) Reporter() result.Reporter

func (*Result) SetReport

func (r *Result) SetReport(report result.Reporter)

SetReport

func (*Result) String

func (r *Result) String() string

String

func (*Result) Template

func (r *Result) Template() string

type Test

type Test struct {
	Id        bson.ObjectId `bson:"_id"`
	ProjectId bson.ObjectId `bson:"projectid"`
	Name      string        `bson:"name"`
	Package   string        `bson:"pkg"`
	Time      int64         `bson:"time"`
	Type      Type          `bson:"type"`
	Target    *tool.Target  `bson:"target"`
	//The test file
	Test []byte `bson:"test"`
	//The data files needed for the test stored in a zip archive
	Data []byte `bson:"data"`
}

Test stores tests for a project.

func NewTest

func NewTest(projectId bson.ObjectId, name string, tipe Type, target *tool.Target, test, data []byte) *Test

NewTest

type TestCase

type TestCase struct {
	ClassName string   `xml:"classname,attr"`
	Name      string   `xml:"name,attr"`
	Time      float64  `xml:"time,attr"`
	Fail      *Failure `xml:"failure"`
}

TestCase represents a failed testcase

func (*TestCase) IsFailure

func (this *TestCase) IsFailure() bool

IsFailure

func (*TestCase) String

func (this *TestCase) String() string

String

type TestCases

type TestCases []*TestCase

TestCases represents all the testcases which a class failed. It implements sort.Sort

func (TestCases) Len

func (this TestCases) Len() int

Len

func (TestCases) Less

func (this TestCases) Less(i, j int) bool

Less

func (TestCases) String

func (this TestCases) String() (ret string)

String

func (TestCases) Swap

func (this TestCases) Swap(i, j int)

Swap

type TestType

type TestType struct {
	ID   Type
	Name string
}

func TestTypes

func TestTypes() []TestType

type Tool

type Tool struct {
	// contains filtered or unexported fields
}

Tool is a tool.T used to run Tool tests on a Java source file.

func New

func New(test, target *tool.Target, toolDir string, testId bson.ObjectId) (*Tool, error)

New creates a new instance of the JUnit Tool. test is the JUnit Test to be run. dir is the location of the submission's tool directory.

func (*Tool) Lang

func (t *Tool) Lang() tool.Language

Lang is Java

func (*Tool) Name

func (t *Tool) Name() string

func (*Tool) Run

func (t *Tool) Run(fileId bson.ObjectId, target *tool.Target) (result.Tooler, error)

Run runs a JUnit test on the provided Java source file. The source and test files are first compiled and we run the tests via a Java runner class which uses ant to generate XML output.

type Type

type Type int
const (
	DEFAULT Type = iota
	ADMIN
	USER
)

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL