Telegram Group & Telegram Channel
Note #29 Testing.short или разделяем тестовые прогоны 📝

Недавно наткнулся на интересную тему: разделение Go тестов на быстрые или медленные те например unit и integration tests. Все собрал в короткую заметку:

A) Стандартный подход использую `testing.Short` [2]:
func TestQuick(t *testing.T) {
...
}

func TestTimeConsuming(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode.")
}
}

Если выполнить:
$ go test -short
То мы пропустим тест TestTimeConsuming и выполним только TestQuick

B) Использовать build tags самый, на мой взгляд, гибкий подход:
Те создаем integration_test.go файл и добавляем билд тэги [1]:
// +build integration

func TestTimeConsuming(t *testing.T) {
// ...
}

Далее просто запускаем:
$ go test -tags=integration

С) Использовать -test.run RegExp [2]:
Можно именовать тесты с префиксом понятным всей команде:
func TestQuickUnit(t *testing.T) {
...
}

func TestIntegraion(t *testing.T) {
...
}

И далее просто:
$ go test -run Integration
$ go test -run Unit

P.S. еще как вариант можно добавить разделение с помощью переменных окружения
А как сделано в вашем проекте? Поделиться можно в личку или чат
Links:
[1] https://golang.org/pkg/go/build/
[2] https://golang.org/cmd/go/#hdr-Testing_flags
[3] https://golang.org/pkg/testing/



tg-me.com/golang_for_two/54
Create:
Last Update:

Note #29 Testing.short или разделяем тестовые прогоны 📝

Недавно наткнулся на интересную тему: разделение Go тестов на быстрые или медленные те например unit и integration tests. Все собрал в короткую заметку:

A) Стандартный подход использую `testing.Short` [2]:

func TestQuick(t *testing.T) {
...
}

func TestTimeConsuming(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode.")
}
}

Если выполнить:
$ go test -short
То мы пропустим тест TestTimeConsuming и выполним только TestQuick

B) Использовать build tags самый, на мой взгляд, гибкий подход:
Те создаем integration_test.go файл и добавляем билд тэги [1]:
// +build integration

func TestTimeConsuming(t *testing.T) {
// ...
}

Далее просто запускаем:
$ go test -tags=integration

С) Использовать -test.run RegExp [2]:
Можно именовать тесты с префиксом понятным всей команде:
func TestQuickUnit(t *testing.T) {
...
}

func TestIntegraion(t *testing.T) {
...
}

И далее просто:
$ go test -run Integration
$ go test -run Unit

P.S. еще как вариант можно добавить разделение с помощью переменных окружения
А как сделано в вашем проекте? Поделиться можно в личку или чат
Links:
[1] https://golang.org/pkg/go/build/
[2] https://golang.org/cmd/go/#hdr-Testing_flags
[3] https://golang.org/pkg/testing/

BY 🇺🇦 Go for two :)


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/golang_for_two/54

View MORE
Open in Telegram


🇺🇦 Go на двоих Telegram | DID YOU KNOW?

Date: |

That growth environment will include rising inflation and interest rates. Those upward shifts naturally accompany healthy growth periods as the demand for resources, products and services rise. Importantly, the Federal Reserve has laid out the rationale for not interfering with that natural growth transition.It's not exactly a fad, but there is a widespread willingness to pay up for a growth story. Classic fundamental analysis takes a back seat. Even negative earnings are ignored. In fact, positive earnings seem to be a limiting measure, producing the question, "Is that all you've got?" The preference is a vision of untold riches when the exciting story plays out as expected.

However, analysts are positive on the stock now. “We have seen a huge downside movement in the stock due to the central electricity regulatory commission’s (CERC) order that seems to be negative from 2014-15 onwards but we cannot take a linear negative view on the stock and further downside movement on the stock is unlikely. Currently stock is underpriced. Investors can bet on it for a longer horizon," said Vivek Gupta, director research at CapitalVia Global Research.

🇺🇦 Go на двоих from us


Telegram 🇺🇦 Go for two :)
FROM USA