-
-
Notifications
You must be signed in to change notification settings - Fork 677
Closed
Description
Hi, we have a use case where currently we used Ginkgo for System Levels E2E API Tests. We leverage the generate
and bootstrap
commands with the --template
to be able to get team members up and running coding new test specs.
That said there are times where we want to modify our template with more variables to inject other metadata during rendering rather than hardcoding it in or modifying it afterwards. Below is an example where we would want to render in the values for .TestSpecName
, .FrameworkImport
, .TestFeature
, .TestComponent
, .TestId
as part of the generate
command of our test spec template.
If you guys are OK with this I would be interested in contributing this to the commands
package {{.Package }}
/* This was generated from a template file. Please feel free to update as necessary */
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"fmt"
"strings"
"time"
"encoding/json"
"context"
//framework imports edit as required
{{ .FrameworkImport }}
)
var _ = framework.{{ .TestSpecName }}SuiteDescribe("{{ .TestSpecName }} tests", Label("{{ .TestFeature }}"), func() {
/* note:
- You may need to implement specific implementation of the service/domain you are trying to test if it
not already there in the pkg/ packages
*/
defer GinkgoRecover()
var err error
var f *framework.Framework
// use 'f' to access common controllers or the specific service controllers within the framework
BeforeAll(func() {
// Initialize the tests controllers
f, err = framework.NewFramework()
Expect(err).NotTo(HaveOccurred())
})
Describe("{{ .TestSpecName }} scenario to test", Label("{{ .TestComponent }}"), func() {
// Declare variables here.
BeforeEach(func() {
// Initialize variables here.
// Assert setup here.
})
It("{{ .TestId }} does some test action", func() {
// Implement test and assertions here
})
})
})
Metadata
Metadata
Assignees
Labels
No labels