sommerfeld-io-archive / source2adoc

Streamline the process of generating AsciiDoc documentation from inline comments within source code files. This tool converts inline documentation into AsciiDoc files, tailored for seamless integration with Antora.
https://source2adoc.sommerfeld.io
Other
0 stars 0 forks source link

Implement acceptance tests / BDD style tests #108

Closed sebastian-sommerfeld-io closed 3 weeks ago

sebastian-sommerfeld-io commented 1 month ago

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 of module github.com/sommerfeld-io/source2adoc-acceptance-tests

Todo Set from Before ADR

Refactoring based on ADR

+--------------------+            +--------------------+
|                    |            |                    |
|  Acceptance Tests  +------------+  Acceptance Tests  |
|                    |            |                    |
+--------------------+            |                    |
            ^                     |                    |
            |                     |     +-----------+  |        +--------------+
            +---------------------------+ script.sh |<----------+ devcontainer |
            build binary          |     +-----------+  |        | post start   |
          copy or reference       +--------------------+        +--------------+
      to use in acceptance tests

With docker compose instead of script.sh somehow?
Before the Dockerfile.app build! 
As part of app-test?

Follow Up Todos

sebastian-sommerfeld-io commented 4 weeks ago

Chat GPT Conversation about structuring my go test code for acceptance tests

Question

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.

Answer

Single acceptance_test.go File

Pros

Cons

*Dedicated `_test.go` File for Each Feature File**

Pros

Cons

Conclusion

The 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.