Skip to content
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

Introduce new testing layout #229

Merged
merged 3 commits into from Jun 7, 2019
Merged

Introduce new testing layout #229

merged 3 commits into from Jun 7, 2019

Conversation

masci
Copy link
Contributor

@masci masci commented Jun 6, 2019

Overview

The project currently has a robust test suite that exercises most of the functionalities against the actual http API. This is not very suitable to iterate fast on the code, thus this PR introduces the concept of unit tests in addition to the existing suite that will stay as it is but will be marked as "integration tests".

Implementation

Integration test functions will contain the string Integration in the name, so that the suite can be run with go test -run integration ./.... Integration tests will be skipped when running unit tests and we use the short option from the Go standard lib to make this easy: each test function will begin like this:

	if testing.Short() {
		t.Skip("skip integration test")
	}

This way, unit tests will be run with just go test -short ./...

To make easier for contributors and the CI to run either of the suites, or both in sequence, a task runner was added. task is written in Go and can be easily installed by just go get so it should be fair to ask developers to have it in their dev env. Available tasks are defined in the Taskfile.yml file, with this PR you can do task test-unit to run all the unit tests, or (for example) task test-unit TARGETS=./auth to run all the unit tests for the auth package only. task test-integration is symmetric while task test will run both integration and unit tests.

Note that go test ./... will keep running all the tests so the use of task is not mandatory.

Copy link
Contributor

@matteosuppo matteosuppo left a comment

Choose a reason for hiding this comment

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

Makes sense to me

@@ -49,7 +57,7 @@ func TestToken(t *testing.T) {
}

// Obtain info
req, err := http.NewRequest("GET", "https://auth.arduino.cc/v1/users/byID/me", nil)
req, err := http.NewRequest("GET", "https://ddauth.arduino.cc/v1/users/byID/me", nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is a typo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(for context, tests are green because this specific test is skipped on Travis, found out when it was too late)

@masci masci merged commit 76c233f into master Jun 7, 2019
@masci masci deleted the massi/test branch June 7, 2019 07:15
mastrolinux pushed a commit that referenced this pull request Jul 16, 2019
Introduce new testing layout
per1234 added a commit that referenced this pull request Aug 9, 2021
Replace broken website publishing script link
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants