-
Notifications
You must be signed in to change notification settings - Fork 10
Tests Качалин Дмитрий #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DmitryNiwa
wants to merge
5
commits into
48x:master
Choose a base branch
from
DmitryNiwa:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| .idea/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| package HomeTusk; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
| import ru.odnoklassniki.ClassToBeTested; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.fail; | ||
|
|
||
| /** | ||
| * Created by Dmitry Kachalin | ||
| * | ||
| * Исходный метод generateIntSequence получает на вход 2 числа типа int: | ||
| * startingNumber - начальное число, от которого будет вестись отсчет. | ||
| * itemsCount - число раз, которое метож будет последовательно прибавлять к исходному числу 1 и записывать получаемые числа в массив. | ||
| * | ||
| * Чек-лист: | ||
| * 1) Проверка случая, когда itemsCount<0 | ||
| * 2) Проверка случая, когда itemsCount=0 | ||
| * 3) Проверка случая, когда startingNumber + itemsCount больше масимального значения типа int | ||
| * 4) Проверка случая, когда startingNumber + itemsCount равно масимальному начению типа int | ||
| * 5) Проверка случая, когда startingNumber + itemsCount меньше максимального значения типа int | ||
| */ | ||
|
|
||
|
|
||
| public class Tests{ | ||
| /** | ||
| * 1) Проверка случая, когда itemsCount<0 | ||
| */ | ||
| @Test | ||
| public void TestIfItemsCountLessThanZero() { | ||
| try{ | ||
| ClassToBeTested.generateIntSequence(500, -5); | ||
| fail(); | ||
| } | ||
| catch(IllegalArgumentException ex){ | ||
| assertEquals("itemsCount must be greater than 0", ex.getMessage()); | ||
|
|
||
| } | ||
| } | ||
|
|
||
| /** | ||
| * 2) Проверка случая, когда itemsCount=0 | ||
| */ | ||
| @Test | ||
| public void TestIfItemsCountEqualsZero() { | ||
| try{ | ||
| ClassToBeTested.generateIntSequence(100,0); | ||
| fail(); | ||
| } | ||
| catch(IllegalArgumentException ex){ | ||
| assertEquals("itemsCount must be greater than 0", ex.getMessage()); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * 3) Проверка случая, когда startingNumber + itemsCount больше масимального значения типа int | ||
| */ | ||
| @Test | ||
| public void TestIfFinishNumberGreaterThanMaxInt(){ | ||
| try{ | ||
| ClassToBeTested.generateIntSequence(Integer.MAX_VALUE - 1, 15); | ||
| fail(); | ||
| } | ||
| catch(IllegalArgumentException ex){ | ||
| assertEquals("can't generate an int greater than integer's max value", ex.getMessage()); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * 4) Проверка случая, когда startingNumber + itemsCount равно масимальному начению типа int | ||
| */ | ||
| @Test | ||
| public void TestIfFinishNumberEqualsManInt(){ | ||
| int startingNumber = Integer.MAX_VALUE - 2; | ||
| int itemsCount = 2; | ||
| ClassToBeTested.generateIntSequence( startingNumber, itemsCount); | ||
| assertEquals(startingNumber + itemsCount,Integer.MAX_VALUE); | ||
| } | ||
|
|
||
| /** | ||
| * 5) Проверка случая, когда startingNumber + itemsCount меньше максимального значения типа int | ||
| */ | ||
| @Test | ||
| public void TestIfEverythingIsNormal(){ | ||
| int startingNumber = 100; | ||
| int itemsCount = 300; | ||
| ClassToBeTested.generateIntSequence(startingNumber, itemsCount); | ||
|
||
| } | ||
| } | ||
Empty file.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+1.16 KB
target/test-classes/ru/odnoklassniki/exampleTests/TestBeforeAndAfter.class
Binary file not shown.
Binary file added
BIN
+718 Bytes
target/test-classes/ru/odnoklassniki/exampleTests/TestBeforeClassAndAfterClass.class
Binary file not shown.
Binary file added
BIN
+345 Bytes
target/test-classes/ru/odnoklassniki/exampleTests/TestHamcrestMatchers.class
Binary file not shown.
Binary file added
BIN
+1.25 KB
target/test-classes/ru/odnoklassniki/exampleTests/TestSampleNegativeTest1.class
Binary file not shown.
Binary file added
BIN
+1.38 KB
target/test-classes/ru/odnoklassniki/exampleTests/TestSampleTest1.class
Binary file not shown.
Binary file added
BIN
+2.2 KB
target/test-classes/ru/odnoklassniki/stringSorter/TestStringSorter.class
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> | ||
| <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5"> | ||
| <output url="file://$MODULE_DIR$/target/classes" /> | ||
| <output-test url="file://$MODULE_DIR$/target/test-classes" /> | ||
| <content url="file://$MODULE_DIR$"> | ||
| <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> | ||
| <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" /> | ||
| <excludeFolder url="file://$MODULE_DIR$/target" /> | ||
| </content> | ||
| <orderEntry type="inheritedJdk" /> | ||
| <orderEntry type="sourceFolder" forTests="false" /> | ||
| <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" /> | ||
| <orderEntry type="library" name="Maven: org.hamcrest:hamcrest-all:1.3" level="project" /> | ||
| <orderEntry type="library" name="Maven: org.junit.jupiter:junit-jupiter-api:5.2.0" level="project" /> | ||
| <orderEntry type="library" name="Maven: org.apiguardian:apiguardian-api:1.0.0" level="project" /> | ||
| <orderEntry type="library" name="Maven: org.opentest4j:opentest4j:1.1.0" level="project" /> | ||
| <orderEntry type="library" name="Maven: org.junit.platform:junit-platform-commons:1.2.0" level="project" /> | ||
| </component> | ||
| </module> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Очень странная проверка, которая никак не связана с функциональностью тестируемого метода.
Надо проверить результат, который отдал тестовый метод. Но кейс, опять-таки, хороший