Skip to content
This repository has been archived by the owner on Jun 3, 2023. It is now read-only.

Create module for app testing #72

Merged
merged 12 commits into from
Oct 6, 2013
Merged

Conversation

mihaibivol
Copy link
Member

Parent issue #71

Need

In order to easily add tests when implementing a feature or solving a bug
As a developer
I want to know where to add new tests

Deliverables

  • A documented way in which tests are added to the project

Solution

  • Move current tests to a tests module
  • Fix failing tests while at it
  • Create files for model tests
  • Add a testing.md doc file in which the testing routine is explained

@ghost ghost assigned mihaibivol Oct 6, 2013
@alexef
Copy link
Member

alexef commented Oct 6, 2013

Bear in mind that django puts tests in corresponding app folders.

On Sunday, 6 October 2013, Mihai Bivol wrote:

Parent issue#71
Need

In order to easily add tests when implementing a feature or solving a bugAs a developerI want to know where to add new tests

Deliverables

  • A documented way in which tests are added to the project

Solution

  • Move current tests to a tests module
  • Create files for eacy type of test ??


Reply to this email directly or view it on GitHubhttps://github.com//issues/72
.

Alex

@mihaibivol
Copy link
Member Author

It's a blogpost in #71. I used those ideas. Also the current tests tested an unused method.


## How to add tests

Anytime you solve a bug or introduce a new feature you need to add a new test
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For bugs there is a need of a regression test first - http://en.wikipedia.org/wiki/Regression_testing.
I would go for the next flow:

  • I found a bug
  • I write a regression test to reproduce the bug
  • I fix the bug and the regression test is failing
  • I fix the test
    Also, tests for bugs should contain a reference to the bug's issue

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can use factories for models? What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do that in this branch?

@alexef alexef closed this Oct 6, 2013
@alexef alexef reopened this Oct 6, 2013
@tiriplicamihai
Copy link
Contributor

cc @mihaibivol Review please

@aburghelea
Copy link

It doesn't really make sense.
IE: I found the bug, i write the test (test is failing), i fix the bug (it should not fail anymore).
There should be no need to fix a test (unless it is badly written).
From what is written above I understand is: I write a bad test, I fix the bug blindly, I fix the test .

@tiriplicamihai
Copy link
Contributor

@icemanftg It may be a little defensive, but I think it's a good way to understand the behaviour and the code before you write a fix. If you think it's overhead then we will drop it.

@mihaibivol
Copy link
Member Author

LGTM. @icemanftg I left it with the following flow:

  • Add a test
  • Fix the bug, test should pass.

It should be clear that if the test is poorly written you will reiterate and rewrite it :)

mihaibivol added a commit that referenced this pull request Oct 6, 2013
@mihaibivol mihaibivol merged commit 86bdcc6 into master Oct 6, 2013
@mihaibivol mihaibivol deleted the 72-create-test-infrastructure branch October 6, 2013 19:30
@aburghelea
Copy link

What I mean is that I do not see a point for writing a test that fails before and after the bug fixed. And to be honest I don't really see how you can do that.
For instance if you have a method that should return the first half of a string and it returns a couple of extra chars. How would the test evolve with each of the steps?

@mihaibivol
Copy link
Member Author

It's updated anyways. The whole idea is if you have a bug, you solve it and add a test. (If something may break write a test) In this instance something is already broken :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants