github.com/redhat-appstudio/e2e-tests@v0.0.0-20230619105049-9a422b2094d7/templates/test_spec_file.tmpl (about)

     1  package {{.SuiteName }}
     2  
     3  /* This was generated from a template file. Please feel free to update as necessary */
     4  
     5  import (
     6  	. "github.com/onsi/ginkgo/v2"
     7  	. "github.com/onsi/gomega"
     8  
     9      "fmt"
    10  	"strings"
    11  	"time"
    12      "encoding/json"
    13      "context"
    14  
    15  
    16      "github.com/redhat-appstudio/e2e-tests/pkg/framework"
    17      //framework imports edit as required
    18      "github.com/redhat-appstudio/e2e-tests/pkg/constants"
    19  	"github.com/redhat-appstudio/e2e-tests/pkg/utils"
    20  
    21  )
    22  
    23  var _ = framework.{{ .TestSpecName }}SuiteDescribe("{{ .TestSpecName }} tests", Label("{{ .TestSpecName }}"), func() {
    24  
    25      /* a couple things to note:
    26      - You may need to implement specific implementation of the service/domain you are trying to test if it
    27      not already there in the pkg/ packages
    28  
    29      - To include the tests as part of the E2E Test suite:
    30         - Update the pkg/framework/describe.go to include the `Describe func` of this new test suite
    31         - Import this new package into the cmd/e2e_test.go 
    32      */
    33  
    34  	defer GinkgoRecover()
    35      var err error
    36      var f *framework.Framework
    37      // use 'f' to access common controllers or the specific service controllers within the framework
    38  	BeforeAll(func() {
    39  		// Initialize the tests controllers
    40  		f, err = framework.NewFramework()
    41  		Expect(err).NotTo(HaveOccurred())
    42  	})
    43  
    44      /* In Gingko, "Describe", "Context", "When" are functionaly the same. They are container nodes that hierarchically 
    45      organize the specs, used to make the flow read better. The core piece of the spec is the subject container, "It", 
    46      this is where the meat of the test is written. 
    47      
    48      Ginkgo's default behavior is to only randomize the order of top-level containers -- the specs within those containers 
    49      continue to run in the order in which they are specified in the test files. That being said, Ginko does provide the 
    50      option to randomize ALL specs. So it is important to design and write test cases for randomization and parallelization
    51      in mind. Tips to do so:
    52      
    53      - Declare variables in "Describe" containers, initialize in "BeforeEach/All" containers
    54      - Move all setup code into "BeforeEach/All" closures 
    55      - "It" containers should be independent of each other. If you require the "It" tests to be dependent on each other for 
    56        complex test scenarios, append into the "Describe" the "Ordered" decorator.
    57      */
    58  
    59      Describe("{{ .TestSpecName }} scenario to test", Label("{{ .TestSpecName }}"), func() {
    60          // Declare variables here.
    61  
    62          BeforeEach(func() {
    63  
    64          // Initialize variables here.
    65          // Assert setup here.
    66  
    67          })
    68  
    69          It("{{ .TestSpecName }} does some test action", func() { 
    70  
    71          // Implement test and assertions here
    72          
    73          })
    74      
    75      })
    76  
    77  })