Skip to content

Commit 3aad8bd

Browse files
committed
Add getting-started in russian
1 parent 08887b2 commit 3aad8bd

File tree

2 files changed

+37
-38
lines changed

2 files changed

+37
-38
lines changed

_ru/getting-started/intellij-track/testing-scala-in-intellij-with-scalatest.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ previous-page: /ru/building-a-scala-project-with-intellij-and-sbt
99

1010
Для Scala существует множество библиотек и методологий тестирования,
1111
но в этом руководстве мы продемонстрируем один популярный вариант из фреймворка ScalaTest
12-
под названием [FunSuite](https://www.scalatest.org/getting_started_with_fun_suite).
12+
под названием [AnyFunSuite](https://www.scalatest.org/getting_started_with_fun_suite).
1313

1414
Это предполагает, что вы знаете, [как создать проект в IntelliJ](building-a-scala-project-with-intellij-and-sbt.html).
1515

@@ -67,6 +67,7 @@ previous-page: /ru/building-a-scala-project-with-intellij-and-sbt
6767
1. Перезапустите тест `CubeCalculatorTest`, кликнув правой кнопкой мыши и выбрав
6868
**Run 'CubeCalculatorTest'**.
6969
70-
## Резюме
70+
## Заключение
7171
Вы видели один из способов тестирования Scala кода.
72-
Узнать больше о FunSuite от ScalaTest можно на [официальном сайте](https://www.scalatest.org/getting_started_with_fun_suite).
72+
Узнать больше о AnyFunSuite от ScalaTest можно на [официальном сайте](https://www.scalatest.org/getting_started_with_fun_suite).
73+
Вы также можете использовать другие тестовые фреймворки, такие как [ScalaCheck](https://www.scalacheck.org/) и [Specs2](https://etorreborre.github.io/specs2/).

_ru/getting-started/sbt-track/testing-scala-with-sbt-on-the-command-line.md

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@ disqus: true
77
previous-page: /ru/getting-started-with-scala-and-sbt-on-the-command-line
88
---
99

10-
There are multiple libraries and testing methodologies for Scala,
11-
but in this tutorial, we'll demonstrate one popular option from the ScalaTest framework
12-
called [AnyFunSuite](https://www.scalatest.org/scaladoc/3.2.2/org/scalatest/funsuite/AnyFunSuite.html).
13-
We assume you know [how to create a Scala project with sbt](getting-started-with-scala-and-sbt-on-the-command-line.html).
10+
Для Scala существует множество библиотек и методологий тестирования,
11+
но в этом руководстве мы продемонстрируем один популярный вариант из фреймворка ScalaTest
12+
под названием [AnyFunSuite](https://www.scalatest.org/getting_started_with_fun_suite).
1413

15-
## Setup
16-
1. On the command line, create a new directory somewhere.
17-
1. `cd` into the directory and run `sbt new scala/scalatest-example.g8`
18-
1. Name the project `ScalaTestTutorial`.
19-
1. The project comes with ScalaTest as a dependency in the `build.sbt` file.
20-
1. `cd` into the directory and run `sbt test`. This will run the test suite
21-
`CubeCalculatorTest` with a single test called `CubeCalculator.cube`.
14+
Это предполагает, что вы знаете, [как создать проект с sbt](getting-started-with-scala-and-sbt-on-the-command-line.html).
15+
16+
## Настройка
17+
1. Используя командную строку создайте новую директорию.
18+
1. Перейдите (`cd`) в этот каталог и запустите `sbt new scala/scalatest-example.g8`.
19+
1. Назовите проект `ScalaTestTutorial`.
20+
1. Проект поставляется с зависимостью ScalaTest в файле `build.sbt`.
21+
1. Перейдите (`cd`) в этот каталог и запустите `sbt test`. Это запустит набор тестов
22+
`CubeCalculatorTest` с одним тестом под названием `CubeCalculator.cube`.
2223

2324
```
2425
sbt test
@@ -35,39 +36,35 @@ sbt test
3536
[success] Total time: 1 s, completed Feb 2, 2017 7:37:31 PM
3637
```
3738

38-
## Understanding tests
39-
1. Open up two files in a text editor:
39+
## Разбор кода
40+
1. Откройте два файла в текстовом редакторе:
4041
* `src/main/scala/CubeCalculator.scala`
4142
* `src/test/scala/CubeCalculatorTest.scala`
42-
1. In the file `CubeCalculator.scala`, you'll see how we define the function `cube`.
43-
1. In the file `CubeCalculatorTest.scala`, you'll see that we have a class
44-
named after the object we're testing.
43+
1. В файле `CubeCalculator.scala` увидите определение функции `cube`.
44+
1. В файле `CubeCalculatorTest.scala` тестируемый класс, названный так же как и объект.
4545

4646
```
4747
import org.scalatest.funsuite.AnyFunSuite
4848
49-
class CubeCalculatorTest extends AnyFunSuite {
49+
class CubeCalculatorTest extends AnyFunSuite:
5050
test("CubeCalculator.cube") {
5151
assert(CubeCalculator.cube(3) === 27)
5252
}
53-
}
5453
```
5554

56-
Let's go over this line by line.
55+
Давайте разберем код построчно:
5756

58-
* `class CubeCalculatorTest` means we are testing the object `CubeCalculator`
59-
* `extends AnyFunSuite` lets us use functionality of ScalaTest's AnyFunSuite class
60-
such as the `test` function
61-
* `test` is function that comes from AnyFunSuite that collects
62-
results from assertions within the function body.
63-
* `"CubeCalculator.cube"` is a name for the test. You can call it anything but
64-
one convention is "ClassName.methodName".
65-
* `assert` takes a boolean condition and determines whether the test passes or fails.
66-
* `CubeCalculator.cube(3) === 27` checks whether the output of the `cube` function is
67-
indeed 27. The `===` is part of ScalaTest and provides clean error messages.
57+
* `class CubeCalculatorTest` означает, что мы тестируем `CubeCalculator`
58+
* `extends AnyFunSuite` позволяет нам использовать функциональность класса AnyFunSuite из ScalaTest,
59+
такую как функция `test`
60+
* `test` это функция из библиотеки FunSuite, которая собирает результаты проверок в теле функции.
61+
* `"CubeCalculator.cube"` - это имя для теста. Вы можете называть тест как угодно, но по соглашению используется имя — "ClassName.methodName".
62+
* `assert` принимает логическое условие и определяет, пройден тест или нет.
63+
* `CubeCalculator.cube(3) === 27` проверяет, действительно ли вывод функции `cube` равен 27.
64+
`===` является частью ScalaTest и предоставляет понятные сообщения об ошибках.
6865

69-
## Adding another test case
70-
1. Add another test block with its own `assert` statement that checks for the cube of `0`.
66+
## Добавление еще одного теста
67+
1. Добавьте еще один тестовый блок с собственным оператором assert, который проверяет 0 в кубе.
7168

7269
```
7370
import org.scalatest.funsuite.AnyFunSuite
@@ -83,7 +80,7 @@ indeed 27. The `===` is part of ScalaTest and provides clean error messages.
8380
}
8481
```
8582
86-
1. Execute `sbt test` again to see the results.
83+
1. Запустите `sbt test` еще раз, чтобы увидеть результаты.
8784
8885
```
8986
sbt test
@@ -102,6 +99,7 @@ indeed 27. The `===` is part of ScalaTest and provides clean error messages.
10299
[success] Total time: 3 s, completed Dec 4, 2019 10:34:04 PM
103100
```
104101
105-
## Conclusion
106-
You've seen one way to test your Scala code. You can learn more about
107-
ScalaTest's FunSuite on the [official website](https://www.scalatest.org/getting_started_with_fun_suite). You can also check out other testing frameworks such as [ScalaCheck](https://www.scalacheck.org/) and [Specs2](https://etorreborre.github.io/specs2/).
102+
## Заключение
103+
Вы видели один из способов тестирования Scala кода.
104+
Узнать больше о AnyFunSuite от ScalaTest можно на [официальном сайте](https://www.scalatest.org/getting_started_with_fun_suite).
105+
Вы также можете использовать другие тестовые фреймворки, такие как [ScalaCheck](https://www.scalacheck.org/) и [Specs2](https://etorreborre.github.io/specs2/).

0 commit comments

Comments
 (0)