Closed sebastian-sommerfeld-io closed 3 weeks ago
Chat GPT Conversation about structuring my go test code for acceptance tests
i have some acceptance tests in my go app in a dedicated component. I use gherkin feature files and godog. works fine.
now I wonder how to structure my test code. I have multiple feature files. i like this because it keeps a clear focus. but they all share some steps. as of now 1 have one single acceptance_test.go file. so all step implementations are part of the same file to avoid spreading my functions too far.
would you recommend keeping 1 acceptance_test.go file or would you use a dedicates test.go file for each feature file?
give me pros and cons for both approaches.
acceptance_test.go
FileThe choice between a single acceptance_test.go
file and multiple dedicated test files depends on your project's size, complexity, and team preferences.
If you find that step definitions are being shared across many features, a middle ground could be to keep shared steps in a separate, common file, and have dedicated test files for feature-specific steps.
Use a flat hierarchy for the tests. No packages, only
*_test.go
files that map to the filenames of the feature files in the main package ofmodule github.com/sommerfeld-io/source2adoc-acceptance-tests
Todo Set from Before ADR
--exclude
featurelocal/source2adoc:dev
locally and use:commit-sha
and:rc
images from pipeline.*_test.go
files (one per feature) or should I combine every test in a singleacceptance_test.go
file? Ask ChatGPT and Copilot.pipeline.yml
against Docker image (:commit-sha
and:rc
) usingCONTAINER_IMAGE=sommerfeldio/source2adoc:<THE_TAG> go test
release.yml
against Docker image (:latest
) usingCONTAINER_IMAGE=sommerfeldio/source2adoc:latest go test
CONTAINER_IMAGE=sommerfeldio/source2adoc:rc go test
and how to run locally and explain that local/source2adoc:dev is default because this allows using the IDE features against a local imagecomponents/test/acceptance-tests/specs/basic.feature
Refactoring based on ADR
components/acceptance-tests
andcomponents/compliance-tests
or similar)CONTAINER_IMAGE
env varContainerUnderTest
, just some simple command that runs the binary directly from a test case.:sha
images:sha
to:rc
by comparing Checksums:rc
to:latest
by comparing Checksumsdocs/modules/ROOT/pages/build-and-release.adoc
docs/modules/ROOT/pages/build-and-release.adoc
(this might be better because everything will be in one place) ... Or maybe include a partial? But then information is duplicated.docs/modules/ROOT/pages/build-and-release.adoc
to multistage docs from Docker imagedocs/modules/ROOT/pages/project-structure.adoc
Follow Up Todos