Documentation
¶
Overview ¶
Package test contains the test harness, which controls browser based tests. Tests should call RegisterTestFunction to register a particular test. These tests get presented to the user in the test form available at the address "/test", and the user can select a test and execute it. The form is also a repository for operations you can perform on the form being tested. A test generally should start with a call to LoadURL. Follow that with calls to control the form and check for expected results. page/test contains a variety of tests that serve to unit test the form framework.
Index ¶
- Constants
- func GetTestForm() page.FormI
- func NewTestForm(ctx context.Context) page.FormI
- func RegisterTestFunction(name string, f testRunnerFunction)
- func TestAssets() string
- func TestStepEvent() *testStepEvent
- type TestController
- func (p *TestController) Action(ctx context.Context, a page.ActionParams)
- func (p *TestController) Init(self control.PanelI, parent page.ControlI, id string)
- func (p *TestController) PutCustomScript(ctx context.Context, response *page.Response)
- func (p *TestController) UpdateFormValues(ctx *page.Context)
- type TestForm
- func (f *TestForm) Action(ctx context.Context, a page.ActionParams)
- func (form *TestForm) AddHeadTags()
- func (f *TestForm) AssertEqual(expected, actual interface{})
- func (f *TestForm) CallJqueryFunction(id string, funcName string, params []string) string
- func (f *TestForm) ChangeVal(id string, val interface{})
- func (f *TestForm) Click(id string)
- func (f *TestForm) CloseWindow()
- func (f *TestForm) Done(s string)
- func (form *TestForm) DrawTemplate(ctx context.Context, buf *bytes.Buffer) (err error)
- func (f *TestForm) Error(message string)
- func (f *TestForm) Fatal(message string)
- func (f *TestForm) Focus(id string)
- func (f *TestForm) GetForm() page.FormI
- func (f *TestForm) LoadControls(ctx context.Context)
- func (f *TestForm) LoadUrl(url string)
- func (f *TestForm) Log(s string)
Constants ¶
const (
TestButtonAction = iota + 1
)
const TestFormId = "TestForm"
const TestFormPath = "/test"
const (
TestStepAction = iota + 100
)
Variables ¶
This section is empty.
Functions ¶
func GetTestForm ¶
GetTestForm returns the test form itself, if its loaded
func RegisterTestFunction ¶
func RegisterTestFunction(name string, f testRunnerFunction)
RegisterTestFunction registers the test and presents it in the list of tests that can be performed.
func TestAssets ¶
func TestAssets() string
Types ¶
type TestController ¶
func NewTestController ¶
func NewTestController(parent page.ControlI, id string) *TestController
func (*TestController) Action ¶
func (p *TestController) Action(ctx context.Context, a page.ActionParams)
func (*TestController) PutCustomScript ¶
func (p *TestController) PutCustomScript(ctx context.Context, response *page.Response)
func (*TestController) UpdateFormValues ¶
func (p *TestController) UpdateFormValues(ctx *page.Context)
type TestForm ¶
type TestForm struct {
page.ΩFormBase
TestList *SelectList
RunningLabel *Span
RunButton *Button
Controller *TestController
// contains filtered or unexported fields
}
func (*TestForm) AddHeadTags ¶
func (form *TestForm) AddHeadTags()
func (*TestForm) AssertEqual ¶
func (f *TestForm) AssertEqual(expected, actual interface{})
AssertEqual will test that the two values are equal, and will error if they are not equal. The test will continue after this.
func (*TestForm) CallJqueryFunction ¶
CallJqueryFunction will call the given function with the given parameters on the jQuery object specified by the id. It will return the javascript result of the function call.
func (*TestForm) ChangeVal ¶
ChangeVal will change the value of a form object. It essentially calls the jQuery .val() function on the html object with the given id, followed by sending a change event to the object. This is not quite the same thing as what happens when a user changes a value, as text boxes may send input events, and change is fired on some objects only when losing focus. However, this will simulate changing a value adequately for most situations.
func (*TestForm) Click ¶
Click sends a click event to the html object with the given id. Note that this is not the same as simulating a click but for buttons, it will essentially be the same thing. More complex web objects will need a different mechanism for clicking, likely a chromium driver or something similar.
func (*TestForm) CloseWindow ¶
func (f *TestForm) CloseWindow()