Skip to content

Commit 439602a

Browse files
committed
Add getting-started in russian
1 parent 831d6f3 commit 439602a

File tree

5 files changed

+52
-68
lines changed

5 files changed

+52
-68
lines changed

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

+3-6
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@ This assumes you know [how to build a project in IntelliJ](building-a-scala-proj
3131
1. Call it `CubeCalculator`, change the **Kind** to `object`, and hit enter or double-click on `object`.
3232
1. Replace the code with the following:
3333
```
34-
object CubeCalculator extends App {
35-
def cube(x: Int) = {
34+
object CubeCalculator:
35+
def cube(x: Int) =
3636
x * x * x
37-
}
38-
}
3937
```
4038
4139
## Creating a test
@@ -46,11 +44,10 @@ This assumes you know [how to build a project in IntelliJ](building-a-scala-proj
4644
```
4745
import org.scalatest.funsuite.AnyFunSuite
4846
49-
class CubeCalculatorTest extends AnyFunSuite {
47+
class CubeCalculatorTest extends AnyFunSuite:
5048
test("CubeCalculator.cube") {
5149
assert(CubeCalculator.cube(3) === 27)
5250
}
53-
}
5451
```
5552
1. In the source code, right-click `CubeCalculatorTest` and select
5653
**Run 'CubeCalculatorTest'**.

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

+4-7
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@ Scala には複数のライブラリとテスト方法がありますが、こ
2626
1. クラスに `CubeCalculator` と名前をつけて、**Kind** を `object` に変更し、**OK** をクリックします。
2727
1. コードを次の通り置き換えます。
2828
```
29-
object CubeCalculator extends App {
30-
def cube(x: Int) = {
29+
object CubeCalculator:
30+
def cube(x: Int) =
3131
x * x * x
32-
}
33-
}
3432
```
3533
3634
## テストを作成
@@ -39,13 +37,12 @@ Scala には複数のライブラリとテスト方法がありますが、こ
3937
1. クラスに `CubeCalculatorTest` と名前を付けて、**OK** をクリックします。
4038
1. コードを次の通り置き換えます。
4139
```
42-
import org.scalatest.FunSuite
40+
import org.scalatest.funsuite.AnyFunSuite
4341
44-
class CubeCalculatorTest extends FunSuite {
42+
class CubeCalculatorTest extends AnyFunSuite:
4543
test("CubeCalculator.cube") {
4644
assert(CubeCalculator.cube(3) === 27)
4745
}
48-
}
4946
```
5047
1. `CubeCalculatorTest` のソースコード内で右クリックし、**Run 'CubeCalculatorTest'** を選択します。
5148

_ru/getting-started/intellij-track/building-a-scala-project-with-intellij-and-sbt.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ sbt создает множество каталогов, которые мог
7373
1. В поле **Tasks**, введите `~run`. `~` заставляет sbt перекомпилировать
7474
и повторно запускать проект при каждом сохранении изменений в файле проекта.
7575
1. Нажмите **OK**.
76-
1. В меню **Run** нажмите **'Run the program'**.
76+
1. В меню **Run** нажмите **Run 'Run the program'**.
7777
1. В коде измените `75` на `61` и посмотрите на обновленные результаты в консоли.
7878

7979
## Добавление зависимости

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

+41-48
Original file line numberDiff line numberDiff line change
@@ -7,73 +7,66 @@ disqus: true
77
previous-page: /ru/building-a-scala-project-with-intellij-and-sbt
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 [FunSuite](https://www.scalatest.org/getting_started_with_fun_suite).
10+
Для Scala существует множество библиотек и методологий тестирования,
11+
но в этом руководстве мы продемонстрируем один популярный вариант из фреймворка ScalaTest
12+
под названием [FunSuite](https://www.scalatest.org/getting_started_with_fun_suite).
1313

14-
This assumes you know [how to build a project in IntelliJ](building-a-scala-project-with-intellij-and-sbt.html).
14+
Это предполагает, что вы знаете, [как создать проект в IntelliJ](building-a-scala-project-with-intellij-and-sbt.html).
1515

16-
## Setup
17-
1. Create an sbt project in IntelliJ.
18-
1. Add the ScalaTest dependency:
19-
1. Add the ScalaTest dependency to your `build.sbt` file:
16+
## Настройка
17+
1. Создайте sbt проект в IntelliJ.
18+
1. Добавьте зависимость ScalaTest:
19+
1. Добавьте зависимость ScalaTest в свой файл `build.sbt`:
2020
```
2121
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.11" % Test
2222
```
23-
1. If you get a notification "build.sbt was changed", select **auto-import**.
24-
1. These two actions will cause `sbt` to download the ScalaTest library.
25-
1. Wait for the `sbt` sync to finish; otherwise, `AnyFunSuite` and `test()` will be
26-
unrecognized.
27-
1. On the project pane on the left, expand `src` => `main`.
28-
1. Right-click on `scala` and select **New** => **Scala class**.
29-
1. Call it `CubeCalculator`, change the **Kind** to `object`, and hit enter or double-click on `object`.
30-
1. Replace the code with the following:
23+
1. Если вы получили уведомление "build.sbt was changed", выберите **auto-import**.
24+
1. Эти два действия заставят `sbt` подгрузить библиотеки ScalaTest.
25+
1. Дождитесь окончания синхронизации `sbt`; в противном случае, `AnyFunSuite` и `test()` не будет распознаны.
26+
1. На панели проекта слева разверните `src` => `main`.
27+
1. Щелкните правой кнопкой мыши на `scala` и выберите **New** => **Scala class**.
28+
1. Назовите новый класс `CubeCalculator`, измените **Kind** на `object`, или дважды щелкните на `object`.
29+
1. Вставьте следующий код:
3130
```
32-
object CubeCalculator extends App {
33-
def cube(x: Int) = {
31+
object CubeCalculator:
32+
def cube(x: Int) =
3433
x * x * x
35-
}
36-
}
3734
```
3835
39-
## Creating a test
40-
1. On the project pane on the left, expand `src` => `test`.
41-
1. Right-click on `scala` and select **New** => **Scala class**.
42-
1. Name the class `CubeCalculatorTest` and hit enter or double-click on `class`.
43-
1. Replace the code with the following:
36+
## Создание теста
37+
1. На панели проекта слева разверните `src` => `test`.
38+
1. Щелкните правой кнопкой мыши на `scala` и выберите **New** => **Scala class**.
39+
1. Назовите новый класс `CubeCalculatorTest` и нажмите **Enter** или дважды щелкните на `class`.
40+
1. Вставьте следующий код:
4441
```
4542
import org.scalatest.funsuite.AnyFunSuite
4643
47-
class CubeCalculatorTest extends AnyFunSuite {
44+
class CubeCalculatorTest extends AnyFunSuite:
4845
test("CubeCalculator.cube") {
4946
assert(CubeCalculator.cube(3) === 27)
5047
}
51-
}
5248
```
53-
1. In the source code, right-click `CubeCalculatorTest` and select
49+
1. В исходном коде щелкните правой кнопкой мыши на `CubeCalculatorTest` и выберите
5450
**Run 'CubeCalculatorTest'**.
5551
56-
## Understanding the code
52+
## Разбор кода
5753
58-
Let's go over this line by line:
54+
Давайте разберем код построчно:
5955
60-
* `class CubeCalculatorTest` means we are testing the object `CubeCalculator`
61-
* `extends AnyFunSuite` lets us use functionality of ScalaTest's AnyFunSuite class
62-
such as the `test` function
63-
* `test` is a function that comes from the FunSuite library that collects
64-
results from assertions within the function body.
65-
* `"CubeCalculator.cube"` is a name for the test. You can call it anything but
66-
one convention is "ClassName.methodName".
67-
* `assert` takes a boolean condition and determines whether the test passes or fails.
68-
* `CubeCalculator.cube(3) === 27` checks whether the output of the `cube` function is
69-
indeed 27. The `===` is part of ScalaTest and provides clean error messages.
56+
* `class CubeCalculatorTest` означает, что мы тестируем `CubeCalculator`
57+
* `extends AnyFunSuite` позволяет нам использовать функциональность класса AnyFunSuite из ScalaTest,
58+
такую как функция `test`
59+
* `test` это функция из библиотеки FunSuite, которая собирает результаты проверок в теле функции.
60+
* `"CubeCalculator.cube"` - это имя для теста. Вы можете называть тест как угодно, но по соглашению используется имя — "ClassName.methodName".
61+
* `assert` принимает логическое условие и определяет, пройден тест или нет.
62+
* `CubeCalculator.cube(3) === 27` проверяет, действительно ли вывод функции `cube` равен 27.
63+
`===` является частью ScalaTest и предоставляет понятные сообщения об ошибках.
7064
71-
## Adding another test case
72-
1. Add another `assert` statement after the first one that checks for the cube
73-
of `0`.
74-
1. Re-run the test again by right-clicking `CubeCalculatorTest` and selecting
75-
'Run **CubeCalculatorTest**'.
65+
## Добавление еще одного теста
66+
1. Добавьте еще один оператор `assert` после первого, который проверяет 0 в кубе.
67+
1. Перезапустите тест `CubeCalculatorTest`, кликнув правой кнопкой мыши и выбрав
68+
**Run 'CubeCalculatorTest'**.
7669
77-
## Conclusion
78-
You've seen one way to test your Scala code. You can learn more about ScalaTest's
79-
FunSuite on the [official website](https://www.scalatest.org/getting_started_with_fun_suite).
70+
## Резюме
71+
Вы видели один из способов тестирования Scala кода.
72+
Узнать больше о FunSuite от ScalaTest можно на [официальном сайте](https://www.scalatest.org/getting_started_with_fun_suite).

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

+3-6
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@ previous-page: /uk/building-a-scala-project-with-intellij-and-sbt
2828
1. Назвіть його `CubeCalculator` та змініть **Kind** на `object` та натисніть Enter або двічі клацніть на `object`.
2929
1. Замініть код на наступний:
3030
```
31-
object CubeCalculator extends App {
32-
def cube(x: Int) = {
31+
object CubeCalculator:
32+
def cube(x: Int) =
3333
x * x * x
34-
}
35-
}
3634
```
3735
3836
## Створення тесту
@@ -43,11 +41,10 @@ previous-page: /uk/building-a-scala-project-with-intellij-and-sbt
4341
```
4442
import org.scalatest.funsuite.AnyFunSuite
4543
46-
class CubeCalculatorTest extends AnyFunSuite {
44+
class CubeCalculatorTest extends AnyFunSuite:
4745
test("CubeCalculator.cube") {
4846
assert(CubeCalculator.cube(3) === 27)
4947
}
50-
}
5148
```
5249
1. У початковому коді клацніть правою кнопкою миші на `CubeCalculatorTest` та оберіть **Run 'CubeCalculatorTest'**.
5350

0 commit comments

Comments
 (0)