@@ -5,17 +5,21 @@ import (
55 "github.com/SimonBaeumer/commander/pkg/runtime"
66)
77
8- // Suite represents the current tests and configs
8+ // Suite represents the current tests, nodes and configs.
9+ // It is used by the runtime to execute all tests and is an abstraction for the given source.
10+ // In example it could be possible to add more formats like XML or a custom DSL implementation.
911type Suite struct {
1012 TestCases []runtime.TestCase
1113 Config runtime.TestConfig
1214 Nodes []runtime.Node
1315}
1416
17+ // GetNodes returns all nodes defined in the suite
1518func (s Suite ) GetNodes () []runtime.Node {
1619 return s .Nodes
1720}
1821
22+ // GetNodeByName returns a node by the given name
1923func (s Suite ) GetNodeByName (name string ) (runtime.Node , error ) {
2024 for _ , n := range s .Nodes {
2125 if n .Name == name {
@@ -25,6 +29,8 @@ func (s Suite) GetNodeByName(name string) (runtime.Node, error) {
2529 return runtime.Node {}, fmt .Errorf ("could not find node with name %s" , name )
2630}
2731
32+ // AddTest pushes a new test to the suite
33+ // if the test was already added it will panic
2834func (s Suite ) AddTest (t runtime.TestCase ) {
2935 if _ , err := s .GetTestByTitle (t .Title ); err == nil {
3036 panic (fmt .Sprintf ("Tests %s was already added to the suite" , t .Title ))
@@ -37,6 +43,7 @@ func (s Suite) GetTests() []runtime.TestCase {
3743 return s .TestCases
3844}
3945
46+ // GetTestByTitle returns a test by title, if the test was not found an error is returned
4047func (s Suite ) GetTestByTitle (title string ) (runtime.TestCase , error ) {
4148 for _ , t := range s .GetTests () {
4249 if t .Title == title {
@@ -46,6 +53,7 @@ func (s Suite) GetTestByTitle(title string) (runtime.TestCase, error) {
4653 return runtime.TestCase {}, fmt .Errorf ("could not find test %s" , title )
4754}
4855
56+ // GetGlobalConfig returns the global configuration which applies to the complete suite
4957func (s Suite ) GetGlobalConfig () runtime.TestConfig {
5058 return s .Config
5159}
0 commit comments