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.

Enforcing DRY principles -- Optimization of test suites

See original GitHub issue

Describe the enhancement Currently, there are many tests that are repetitive, i.e: For example:

def test_issue_comments_mean_std_by_group(metrics):
    response = requests.get('http://localhost:5000/api/unstable/repo-groups/10/issue-comments-mean-std')
    data = response.json()
    assert response.status_code == 200
    assert len(data) >= 1

def test_issue_comments_mean_std_by_repo(metrics):
    response = requests.get('http://localhost:5000/api/unstable/repo-groups/10/repos/25430/issue-comments-mean-std')
    data = response.json()
    assert response.status_code == 200
    assert len(data) >= 1

def test_issue_comments_mean_std_by_repo(metrics):
    response = requests.get('http://localhost:5000/api/unstable/repo-groups/10/repos/25430/issue-comments-mean-std')
    data = response.json()
    assert response.status_code == 200
    assert len(data) >= 1

Instead of this, we could write a common function that could be called across these tests to incorporate readability, reusability and proper maintenance.

Additional info Working on this.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
sgogginscommented, Apr 9, 2020

@mrsaicharan1 : OK … you might need to open a new PR, as we merged the first one!

0reactions
sgogginscommented, Aug 20, 2020

Great!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Keep Your Tests DRY - Telerik
Approach the design, implementation, and maintenance of your test suites with the same engineering and craftsman mindset you approach the design ...
Read more >
A Better Definition of the DRY Programming Principle
One of the most frequently disregarded and misunderstood coding principle by junior developers is the DRY principle which stands for Don't Repeat Yourself....
Read more >
Doesn't the DRY principle apply as much to testing code as ...
Nope. Test code should ideally be self-contained. Each testcase should be considered a separate program, independent of all other testcases and should be...
Read more >
Why is DRY important? - Software Engineering Stack Exchange
DRY is a principle of software development aimed at reducing repetition of information of all kinds. Every piece of knowledge must have a...
Read more >
DRY is an over-rated programming principle? - Hacker News
I found that approach much easier to test the functions and catch bugs, ... The DRY principle is intending to get you thinking...
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