Better document testing
See original GitHub issueHi, neither the docs or code examples mention how to set up tests - which I think is important for any non trivial function.
I currently hook up my tests like this:
from flask import testing
import pytest
from functions_framework import create_app
import pathlib
@pytest.fixture
def client() -> testing.Client:
target = "function_name"
source = pathlib.Path(__file__).parent.parent / "main.py"
with create_app(target, str(source)).test_client() as client:
yield client
def test_something(client: testing.Client):
rv = client.post('/', data="no json")
assert rv.status_code == 400
this assumes that the test file is inside a test folder.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Test Documentation in Software Testing - Mad Devs
Good test documentation is an excellent demonstration of how seriously you take your services and applications' security, stability, and speed.
Read more >Test Documentation in Software Testing (Example) - Guru99
Test documentation is documentation of artifacts created before or during the testing of software. It helps the testing team to estimate testing ......
Read more >Software Testing Documentation Guide (Why It's Important)
Test Documentation : What's That? · Clarify quality objective and methods. · Ensure clarity about tasks and consistency of performance. · Ensure ...
Read more >Test Documentation : Types, Best Practices, Merits and Demerits
The testing team uses the test documentation to estimate the testing effort (that is needed), execution progress, resource tracking and test ...
Read more >Tests Are The Best Kind Of Documentation - mokacoding
Unit tests are a vital tool for writing quality code. They also happen to be the best kind of documentation for your software,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think it is also functions framework documentation - the framework abstracts away some details and that makes it difficult to get integration test up and running.
The entry for integration testing is only for node currently: https://cloud.google.com/functions/docs/testing/test-http#integration_tests
I would suggest adding a paragraph detailing how to set up IT tests for this framework in this repo, e.g. showing how to get the testing.Client and how to work with it. That way, people don’t have to know the internals of flask to work with the functions framework.
@ChristianSauer thanks again for filing this issue. Seeing as we’ve added a sample in Python and there hasn’t been much activity on this since then, I’m going to close the issue as fixed.
Please feel free to reopen if this is not in fact fixed, or file a new issue if you have other concerns. Thanks! 🙂