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.
Index ¶
- Constants
- func GetTestForm() page.FormI
- func RegisterTestFunction(name string, f testRunnerFunction)
- func TestMarkerEvent() *event.Event
- func TestStepEvent() *event.Event
- type JsUnitForm
- type TestController
- type TestForm
- func (ctrl *TestForm) AddHeadTags()
- func (form *TestForm) AssertEqual(expected, actual interface{})
- func (form *TestForm) AssertNil(v interface{})
- func (form *TestForm) AssertNotNil(v interface{})
- func (form *TestForm) CallControlFunction(id string, funcName string, params ...interface{}) interface{}
- func (form *TestForm) ChangeVal(id string, val interface{})
- func (form *TestForm) CheckGroup(id string, values ...string)
- func (form *TestForm) ChooseListValue(id string, value string)
- func (form *TestForm) ChooseListValues(id string, values ...string)
- func (form *TestForm) Click(id string)
- func (form *TestForm) ClickHtmlItem(id string)
- func (form *TestForm) ClickSubItem(id string, subId string)
- func (form *TestForm) CloseWindow()
- func (form *TestForm) ControlAttribute(id string, attribute string) interface{}
- func (form *TestForm) ControlHasClass(id string, needle string) bool
- func (form *TestForm) ControlInnerHtml(id string) string
- func (form *TestForm) ControlValue(id string) interface{}
- func (form *TestForm) CreateControls(ctx context.Context)
- func (form *TestForm) DoAction(ctx context.Context, a action.Params)
- func (form *TestForm) Done(s string)
- func (ctrl *TestForm) DrawTemplate(ctx context.Context, _w io.Writer) (err error)
- func (form *TestForm) Error(message string)
- func (form *TestForm) Fatal(message string)
- func (form *TestForm) Focus(id string)
- func (form *TestForm) HtmlElementInfo(selector string, attribute string) string
- func (form *TestForm) Init(ctx context.Context, formID string)
- func (form *TestForm) LoadControls(ctx context.Context)
- func (form *TestForm) LoadUrl(url string)
- func (form *TestForm) Log(s string)
- func (form *TestForm) NoSerialize() bool
- func (form *TestForm) PushRedraw()
- func (form *TestForm) SetCheckbox(id string, val bool)
- func (form *TestForm) WaitMarker(expectedMarker string)
- func (form *TestForm) WaitSubmit()
- func (form *TestForm) WithForm(f func(page.FormI))
Constants ¶
const ( TestButtonAction = iota + 1 TestAllAction )
const JsUnitTestFormId = "JsUnitTestForm"
const JsUnitTestFormPath = "/goradd/test/jsunit.g"
const StepTimeoutSeconds = 10
const TestFormId = "TestForm"
const TestFormPath = "/goradd/Test.g"
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 TestMarkerEvent ¶ added in v0.12.0
func TestStepEvent ¶
Types ¶
type JsUnitForm ¶ added in v0.2.0
type JsUnitForm struct { FormBase Results *Panel RunButton *Button }
func (*JsUnitForm) AddHeadTags ¶ added in v0.2.0
func (ctrl *JsUnitForm) AddHeadTags()
func (*JsUnitForm) AddRelatedFiles ¶ added in v0.2.0
func (f *JsUnitForm) AddRelatedFiles()
func (*JsUnitForm) DrawTemplate ¶ added in v0.2.0
type TestController ¶
func NewTestController ¶
func NewTestController(parent page.ControlI, id string) *TestController
func (*TestController) DoAction ¶ added in v0.23.0
func (p *TestController) DoAction(ctx context.Context, a action.Params)
func (*TestController) Init ¶
func (p *TestController) Init(self any, parent page.ControlI, id string)
func (*TestController) UpdateFormValues ¶
func (p *TestController) UpdateFormValues(ctx context.Context)
type TestForm ¶
type TestForm struct { FormBase Controller *TestController // contains filtered or unexported fields }
func (*TestForm) AddHeadTags ¶
func (ctrl *TestForm) AddHeadTags()
func (*TestForm) AssertEqual ¶
func (form *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) AssertNotNil ¶ added in v0.0.3
func (form *TestForm) AssertNotNil(v interface{})
func (*TestForm) CallControlFunction ¶ added in v0.2.0
func (form *TestForm) CallControlFunction(id string, funcName string, params ...interface{}) interface{}
CallControlFunction will call the given function with the given parameters on the goradd 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 javascript .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) CheckGroup ¶ added in v0.0.3
CheckGroup sets the checkbox group to a list of values. Radio groups should only be given one value to check. Will uncheck anything checked in the group before checking the given values. Specify nil to uncheck everything.
func (*TestForm) ChooseListValue ¶ added in v0.3.0
func (*TestForm) ChooseListValues ¶ added in v0.3.0
func (*TestForm) Click ¶
Click sends a click to the goradd control. Note that the act of clicking often causes an action, and an action will change the form
func (*TestForm) ClickHtmlItem ¶ added in v0.0.5
func (*TestForm) ClickSubItem ¶ added in v0.0.4
ClickSubItem sends a click to the html object with the given sub-id inside the given control.
func (*TestForm) CloseWindow ¶
func (form *TestForm) CloseWindow()
func (*TestForm) ControlAttribute ¶ added in v0.2.0
ControlAttribute will call the .attr("attribute") function on the given html object looking for the given attribute name and will return the value.
func (*TestForm) ControlHasClass ¶ added in v0.9.3
ControlHasClass will return true if the given goradd control has the given class attribute
func (*TestForm) ControlInnerHtml ¶ added in v0.9.3
ControlInnerHtml will return the inner html drawn by a goradd control
func (*TestForm) ControlValue ¶ added in v0.2.0
ControlValue will call the .val() function on the given goradd object and return the result.
func (*TestForm) CreateControls ¶ added in v0.29.0
func (*TestForm) DrawTemplate ¶
func (*TestForm) HtmlElementInfo ¶ added in v0.9.3
HtmlElementInfo will return the inner html drawn by a goradd control
func (*TestForm) LoadControls ¶
func (*TestForm) LoadUrl ¶
LoadUrl will launch a new window controlled by the test form. It will wait for the new url to be loaded in the window, and if the new url contains a goradd form, it will return the form.
func (*TestForm) NoSerialize ¶ added in v0.3.0
func (*TestForm) PushRedraw ¶ added in v0.3.1
func (form *TestForm) PushRedraw()
func (*TestForm) SetCheckbox ¶ added in v0.0.3
SetCheckbox sets the given checkbox control to the given value. Use this instead of ChangeVal on checkboxes.
func (*TestForm) WaitMarker ¶ added in v0.12.0
WaitMarker waits for a marker event before proceeding. You can use this to signal that your code has reached a specific place. To signal the marker, call FireTestMarker from a control in your application.
func (*TestForm) WaitSubmit ¶ added in v0.0.3
func (form *TestForm) WaitSubmit()