Skip to content

Трофимов Никита#239

Open
WoeromProg wants to merge 4 commits intokontur-courses:masterfrom
WoeromProg:master
Open

Трофимов Никита#239
WoeromProg wants to merge 4 commits intokontur-courses:masterfrom
WoeromProg:master

Conversation

@WoeromProg
Copy link

@VladSavitskiy

Choose a reason for hiding this comment

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

Если есть TestCase, то [Test] писать не нужно, это почти синонимы. Тут и во всех тестах ниже

Choose a reason for hiding this comment

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

Все изощренности с названиями нужны исключительно для читаемости будущих тестов. Ты определенно сделал шаг в этом направлении, надо только чуток докрутить.

  1. Базовая часть названия уже есть в названии метода, дублировать её просто не имеет смысла.
    image

Почему так? Читая тест кейсы в инспекторе, мы и так понимаем, что находимся внутри метода Creation_ShouldThrowArgumentException, поэтому дублирование только создает лишнюю когнитивную нагрузку. Также при переименовании метода, TestName автоматом не обновится, если это не сделает IDE

  1. Когда удалится дублирование, останутся фразы вида When..., от них на самом деле тоже можно избавиться, оставив только самую суть - что проверяет данный тесткейс

  2. Поправить нужно тут и во всех тестах ниже

Choose a reason for hiding this comment

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

Форматирование немного поехало, между аргументами нет пробелов. Важная штука, не забывай перед сдачей на ревью

Choose a reason for hiding this comment

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

Для чего в тесте аргумент onlyPositive, если он всегда равен true?

Choose a reason for hiding this comment

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

Не хватает ещё одного граничного, очень похожего на этот ))

Choose a reason for hiding this comment

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

Во всех методах этого класса потерялась часть, означающая "при каком условии выполняется действие", то есть часть, начинающаяся на _When.... В случае с TestCase желательно обобщить все тесткейсы под одно выражение и записать его в название метода, а сами тесткейсы уже будут пояснять детали своими названиями

Choose a reason for hiding this comment

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

Точно ли здесь учтены все случаи корректной работы метода?

Copy link

@desolver desolver Nov 28, 2023

Choose a reason for hiding this comment

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

Понимаю, что этот файл создавал не ты, но быть может задумка автора как раз и была в том, чтобы с какими-то конвентами знакомить

В большом продакшене придется работать с тысячами файлов и классов, и всегда удобно, когда каждый класс, интерфейс, enum и тд лежит в своем собственном файле. Давай тут сделаем так же

Аналогично с соседним файлом

Choose a reason for hiding this comment

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

Не могу почему-то написать комментарий парой строк выше)) Напишу тут - понятное ли название у теста?

Choose a reason for hiding this comment

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

Замени здесь Василия 3, на Василия 2 и прогони тест, ожидаемое ли это поведение?

Переписал тест с одним testCase
Перенёс тесты в отдельные файлы
Добавил тест в Creation_ShouldThrowArgumentException
Убрал параметр OnlyPositive
Изменил тест для проверки царя
}
}

public class NumberValidator

Choose a reason for hiding this comment

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

Файл все ещё называется NumberValidatorTests)

Choose a reason for hiding this comment

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

И тут название файла не совпадает с названием класса

Comment on lines 32 to 34

Choose a reason for hiding this comment

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

Снова форматирование уехало

creation
.Should()
.NotThrow<Exception>();

Choose a reason for hiding this comment

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

Лишняя строка пустая

using FluentAssertions;
using NUnit.Framework;
using NUnit.Framework.Internal;

Choose a reason for hiding this comment

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

Тоже лишняя пустая строка

Choose a reason for hiding this comment

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

Все ещё нет глагола перед False и True тут и ниже, вспомни про порядок именований в тестах

Method_Should..._When...

Добавил по тесту с onlyPositive = true
Доработал нейминг тестов
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.

2 participants

Comments