KudoZ question not available

Russian translation: вспомогательные функции настройки тестов/проверок

GLOSSARY ENTRY (DERIVED FROM QUESTION BELOW)
English term or phrase:test setup helpers
Russian translation:вспомогательные функции настройки тестов/проверок
Entered by: Andrew Tishin

12:50 Dec 31, 2022
English to Russian translations [PRO]
Tech/Engineering - Computers: Software / Google Go
English term or phrase: test setup helpers
https://google.github.io/styleguide/go/best-practices

However, some situations require that the test not proceed. Calling t.Fatal is appropriate when some piece of test setup fails, especially in **test setup helpers**, without which you cannot run the rest of the test. In a table-driven test, t.Fatal is appropriate for failures that set up the whole test function before the test loop. Failures that affect a single entry in the test table, which make it impossible to continue with that entry, should be reported as follows:

If you’re not using t.Run subtests, use t.Error followed by a continue statement to move on to the next table entry.
If you’re using subtests (and you’re inside a call to t.Run), use t.Fatal, which ends the current subtest and allows your test case to progress to the next subtest.

Warning: It is not always safe to call t.Fatal and similar functions. More details here.
Andrew Tishin
Russian Federation
Local time: 03:24
вспомогательные функции настройки тестов/проверок
Explanation:
First a quick review of the mechanics. When we run go test the go tool generates a main program that runs the test functions for our package. If the go tool finds a TestMain function it instead generates code to call TestMain. A typical TestMain follows.

func TestMain(m *testing.M) {
setup()
code := m.Run()
shutdown()
os.Exit(code)
}
From the above code we can see that writing a TestMain function allows us to control four aspects of test execution.

Setup.
How and when to run the tests.
Shutdown.
Exit behavior.
With appropriate use of these four items, we can satisfy several different use cases that were not well served prior to Go 1.4.

http://cs-guy.com/blog/2015/01/test-main/

--------------------------------------------------
Note added at 46 mins (2022-12-31 13:36:46 GMT)
--------------------------------------------------

Note that I provide argument tb to the setup and teardown functions, in case if we need something from the testing library. So you can leave the function alone without any argument if you want to. Now, if you run the test by running command go test -v, you’ll have something similar with this result printed on your terminal.

https://medium.com/nerd-for-tech/setup-and-teardown-unit-tes...
Selected response from:

Mikhail Zavidin
Local time: 03:24
Grading comment
Спасибо
4 KudoZ points were awarded for this answer



Summary of answers provided
3 +1вспомогательные функции настройки тестов/проверок
Mikhail Zavidin


  

Answers


44 mins   confidence: Answerer confidence 3/5Answerer confidence 3/5 peer agreement (net): +1
вспомогательные функции настройки тестов/проверок


Explanation:
First a quick review of the mechanics. When we run go test the go tool generates a main program that runs the test functions for our package. If the go tool finds a TestMain function it instead generates code to call TestMain. A typical TestMain follows.

func TestMain(m *testing.M) {
setup()
code := m.Run()
shutdown()
os.Exit(code)
}
From the above code we can see that writing a TestMain function allows us to control four aspects of test execution.

Setup.
How and when to run the tests.
Shutdown.
Exit behavior.
With appropriate use of these four items, we can satisfy several different use cases that were not well served prior to Go 1.4.

http://cs-guy.com/blog/2015/01/test-main/

--------------------------------------------------
Note added at 46 mins (2022-12-31 13:36:46 GMT)
--------------------------------------------------

Note that I provide argument tb to the setup and teardown functions, in case if we need something from the testing library. So you can leave the function alone without any argument if you want to. Now, if you run the test by running command go test -v, you’ll have something similar with this result printed on your terminal.

https://medium.com/nerd-for-tech/setup-and-teardown-unit-tes...

Mikhail Zavidin
Local time: 03:24
Works in field
Native speaker of: Native in RussianRussian
PRO pts in category: 199
Grading comment
Спасибо

Peer comments on this answer (and responses from the answerer)
agree  Ilian DAVIAUD
1 hr
  -> Спасибо
Login to enter a peer comment (or grade)



Login or register (free and only takes a few minutes) to participate in this question.

You will also have access to many other tools and opportunities designed for those who have language-related jobs (or are passionate about them). Participation is free and the site has a strict confidentiality policy.

KudoZ™ translation help

The KudoZ network provides a framework for translators and others to assist each other with translations or explanations of terms and short phrases.


See also:
Term search
  • All of ProZ.com
  • Term search
  • Jobs
  • Forums
  • Multiple search