-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvements to integration tests #33203
Comments
Agree to improve the tests.
Yep, we should encourage developers to write more informative comments, not only in tests.
Agree, some existing fixtures are good enough for most cases. For special cases, we should create users or repositories during the tests. (I have stopped some PRs from adding more rows in "user.yml" or more files like "new-test.git", maybe it won't make everyone happy but I think it is still right to keep the tests clear).
Not sure whether it really helps (or what's your proposal to do so). In most cases, I just click the "Run" icon in my IDE and only run the test I am working on (screenshot):There are also some Makefile commands (but I seldom use them):
|
I don't remember if I tried it to be honest - I think they failed because some env vars are set when ran with make. But with a "tag system" I means something more in the direction of "I've modified something with that touched pull request code. I want to start all tests which are related to pull requests". Then again this is more a QoL thing than something major. As for the fixtures - I meant that currently instead of making a new user and configuring them for the specific test, it's more natural to look for the preloaded user, which causes a loop of sorts - Pick a user, pick a repo, test fails because repo is private and that's the only repo user has, pick a new set and so on. Basic test example that I'm used to// Runs things that all test from the file need
func SetupSuite(){
// We want an user with repository
user:= admin.CreateUser()
repo:=user.CreateRepository()
}
func TeardownSuite(){
user.DeleteRepository(repo)
admin.DeleteUser(user)
}
// Scenario
func UserCanMakeRepoPrivate(){
teardown:=func(){
repo.SetPrivate(false)
}
repo.SetPrivate(true)
assert.True(repo.Private)
} At the very least, documenting how to set instance with fixtures up and the relations of users/repos in fixtures would be good to start with. I'll try looking into how integrations tests are done when I have some time. |
Feature Description
While writing integration test for pull request template I had some difficulties with getting it to work initially. I observed the following issues:
I have some idea of how tests could look like but I'd like to open a discussion about it first. Some of my ideas:
user1
is used for this test. IMO each test should setup it's own preconditions1 or at minimum explain what they are.Blackbox tests would be nice too but those don't provide measurable coverage.
Screenshots
No response
Footnotes
That isn't to say that loading the database isn't useful - I'm sure it is to trigger something very specific, I haven't delved that deep to find an example for it. On the other hand I think that having
userCreate(opts)
or similar which can use web/api to do it and mimics what the end user can actually do is more friendly and will help to have more approachable tests. ↩The text was updated successfully, but these errors were encountered: