question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Better document testing

See original GitHub issue

Hi, 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ChristianSauercommented, May 15, 2020

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.

0reactions
ace-ncommented, Jan 22, 2021

@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! 🙂

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found