go-bdd / gobdd

BDD framework
https://go-bdd.github.io/gobdd/
MIT License
115 stars 19 forks source link

Store Feature and Scenario in test context #140

Closed jirikuncar closed 2 years ago

jirikuncar commented 2 years ago

closes #121

bkielbasa commented 2 years ago

@jirikuncar thanks for the PR! Looks good to me. Could you fix the linter issue?

jirikuncar commented 2 years ago

Any of these issues is related to my change:

gobdd.go:42:9: runInParallel is missing in SuiteOptions (exhaustivestruct)
    return SuiteOptions{
           ^
gobdd.go:146:8: hasStepErrors is missing in Suite (exhaustivestruct)
    s := &Suite{
          ^
gobdd.go:397:12: Id is missing in GherkinDocument_Feature_Step (exhaustivestruct)
        step := &msgs.GherkinDocument_Feature_Step{
                 ^
gobdd.go:577:27: expr, f are missing in stepDef (exhaustivestruct)
    if reflect.DeepEqual(sd, stepDef{}) {
                             ^
gobdd_test.go:85:56: Location, Id are missing in GherkinDocument_Feature_TableRow (exhaustivestruct)
    st, expr := s.stepFromExample("I add <d1> and <d2>", &msgs.GherkinDocument_Feature_TableRow{
                                                          ^
gobdd_test.go:216:15: fatalCalled, errors are missing in mockTester (exhaustivestruct)
            tester := &mockTester{}
                       ^
gobdd_test.go:241:11: expr is missing in stepDef (exhaustivestruct)
            def := stepDef{f: testCase.f}
                   ^
gobdd_test.go:243:15: fatalCalled, errors are missing in mockTester (exhaustivestruct)
            tester := &mockTester{}
                       ^
steps_test.go:30:70: values is missing in Context (exhaustivestruct)
    if err := validateStepFunc(func(StepTest, Context) Context { return Context{} }); err != nil {
                                                                        ^
gobdd.go:541:3: type assertion must be checked (forcetypeassert)
        s := paramType.Interface().([]uint8)
        ^
gobdd.go:547:3: type assertion must be checked (forcetypeassert)
        s := paramType.Interface().([]uint8)
        ^
gobdd.go:553:3: type assertion must be checked (forcetypeassert)
        s := paramType.Interface().([]uint8)
        ^
gobdd.go:242:2: variable 'err' is only used in the if-statement (gobdd.go:243:2); consider using short syntax (ifshort)
    err := validateStepFunc(step)
    ^
gobdd.go:309:2: variable 'hasErrors' is only used in the if-statement (gobdd.go:333:2); consider using short syntax (ifshort)
    hasErrors := false
    ^
gobdd.go:305:4: return with no blank line before (nlreturn)
            return nil
            ^
gobdd.go:326:5: continue with no blank line before (nlreturn)
                continue
                ^
gobdd_test.go:280:3: return with no blank line before (nlreturn)
        return
        ^
context_get_as_test.go:9:1: Function TestContext_GetAs_NoPointerType missing the call to method parallel (paralleltest)
func TestContext_GetAs_NoPointerType(t *testing.T) {
^
context_get_as_test.go:19:1: Function TestContext_GetAs_WithSlice missing the call to method parallel (paralleltest)
func TestContext_GetAs_WithSlice(t *testing.T) {
^
context_get_as_test.go:30:1: Function TestContext_GetAs_WithMap missing the call to method parallel (paralleltest)
func TestContext_GetAs_WithMap(t *testing.T) {
^
context_test.go:9:1: Function TestContextNilInGetError missing the call to method parallel (paralleltest)
func TestContextNilInGetError(t *testing.T) {
^
gobdd_test.go:13:1: Function TestScenarios missing the call to method parallel (paralleltest)
func TestScenarios(t *testing.T) {
^
gobdd_test.go:23:1: Function TestAddStepWithRegexp missing the call to method parallel (paralleltest)
func TestAddStepWithRegexp(t *testing.T) {
^
gobdd_test.go:31:1: Function TestDifferentFuncTypes missing the call to method parallel (paralleltest)
func TestDifferentFuncTypes(t *testing.T) {
^
gobdd_test.go:39:1: Function TestScenarioOutline missing the call to method parallel (paralleltest)
func TestScenarioOutline(t *testing.T) {
^
gobdd_test.go:47:1: Function TestParameterTypes missing the call to method parallel (paralleltest)
func TestParameterTypes(t *testing.T) {
^
gobdd_test.go:67:1: Function TestScenarioOutlineExecutesAllTests missing the call to method parallel (paralleltest)
func TestScenarioOutlineExecutesAllTests(t *testing.T) {
^
gobdd_test.go:83:1: Function TestStepFromExample missing the call to method parallel (paralleltest)
func TestStepFromExample(t *testing.T) {
^
gobdd_test.go:105:1: Function TestBackground missing the call to method parallel (paralleltest)
func TestBackground(t *testing.T) {
^
gobdd_test.go:113:1: Function TestTags missing the call to method parallel (paralleltest)
func TestTags(t *testing.T) {
^
gobdd_test.go:121:1: Function TestFilterFeatureWithTags missing the call to method parallel (paralleltest)
func TestFilterFeatureWithTags(t *testing.T) {
^
gobdd_test.go:137:1: Function TestWithAfterScenario missing the call to method parallel (paralleltest)
func TestWithAfterScenario(t *testing.T) {
^
gobdd_test.go:149:1: Function TestWithBeforeScenario missing the call to method parallel (paralleltest)
func TestWithBeforeScenario(t *testing.T) {
^
gobdd_test.go:161:1: Function TestWithAfterStep missing the call to method parallel (paralleltest)
func TestWithAfterStep(t *testing.T) {
^
gobdd_test.go:176:1: Function TestWithBeforeStep missing the call to method parallel (paralleltest)
func TestWithBeforeStep(t *testing.T) {
^
gobdd_test.go:191:1: Function TestIgnoredTags missing the call to method parallel (paralleltest)
func TestIgnoredTags(t *testing.T) {
^
gobdd_test.go:197:1: Function TestIgnorFeatureWithTags missing the call to method parallel (paralleltest)
func TestIgnorFeatureWithTags(t *testing.T) {
^
gobdd_test.go:203:1: Function TestInvalidFunctionSignature missing the call to method parallel (paralleltest)
func TestInvalidFunctionSignature(t *testing.T) {
^
gobdd_test.go:214:2: Range statement for test TestInvalidFunctionSignature missing the call to method parallel in test Run (paralleltest)
    for name, testCase := range testCases {
    ^
gobdd_test.go:228:1: Function TestFailureOutput missing the call to method parallel (paralleltest)
func TestFailureOutput(t *testing.T) {
^
gobdd_test.go:239:2: Range statement for test TestFailureOutput missing the call to method parallel in test Run (paralleltest)
    for _, testCase := range testCases {
    ^
steps_test.go:7:1: Function TestValidateStepFunc missing the call to method parallel (paralleltest)
func TestValidateStepFunc(t *testing.T) {
^
steps_test.go:14:2: Range statement for test TestValidateStepFunc missing the call to method parallel in test Run (paralleltest)
    for name, testCase := range testCases {
    ^
steps_test.go:23:1: Function TestValidateStepFunc_ValidFunction missing the call to method parallel (paralleltest)
func TestValidateStepFunc_ValidFunction(t *testing.T) {
^
steps_test.go:29:1: Function TestValidateStepFunc_ReturnContext missing the call to method parallel (paralleltest)
func TestValidateStepFunc_ReturnContext(t *testing.T) {
^
gobdd.go:311:82: test helper function should start from t.Helper() (thelper)
    s.t.Run(fmt.Sprintf("%s %s", strings.TrimSpace(feature.Keyword), feature.Name), func(t *testing.T) {
                                                                                    ^
gobdd.go:448:17: parameter *testing.T should be the first or after context.Context (thelper)
func (s *Suite) runScenario(ctx Context, scenario *msgs.GherkinDocument_Feature_Scenario,
                ^
gobdd.go:474:17: parameter *testing.T should be the first or after context.Context (thelper)
func (s *Suite) runSteps(ctx Context, t *testing.T, steps []*msgs.GherkinDocument_Feature_Step) {
                ^
gobdd.go:480:17: parameter *testing.T should be the first or after context.Context (thelper)
func (s *Suite) runStep(ctx Context, t *testing.T, step *msgs.GherkinDocument_Feature_Step) {
                ^
context.go:62:10: error returned from external package is unwrapped: sig: func encoding/json.Marshal(v interface{}) ([]byte, error) (wrapcheck)
        return err
               ^
context.go:65:9: error returned from external package is unwrapped: sig: func encoding/json.Unmarshal(data []byte, v interface{}) error (wrapcheck)
    return json.Unmarshal(d, dest)
           ^
steps_context_test.go:10:1: Function TestValidateStepFunc_Context missing the call to method parallel (paralleltest)
func TestValidateStepFunc_Context(t *testing.T) {
^
steps_context_test.go:15:2: Range statement for test TestValidateStepFunc_Context missing the call to method parallel in test Run (paralleltest)
    for name, testCase := range testCases {
    ^
steps_context_test.go:24:1: Function TestValidateStepFunc_ValidFunction_Context missing the call to method parallel (paralleltest)
func TestValidateStepFunc_ValidFunction_Context(t *testing.T) {
^
steps_context_test.go:30:1: Function TestValidateStepFunc_ReturnContext_Context missing the call to method parallel (paralleltest)
func TestValidateStepFunc_ReturnContext_Context(t *testing.T) {
^
bkielbasa commented 2 years ago

it looks like I'll have to fix those linter issues myself :)

anyway, merging!