Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
alx_java1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
alx_java1
Commits
6fd161af
Commit
6fd161af
authored
Aug 06, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pierwszy test JUnit
parent
27ce0b7f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
pom.xml
pom.xml
+10
-0
SilniaTest.java
src/test/java/p08_funkcje/SilniaTest.java
+26
-0
No files found.
pom.xml
View file @
6fd161af
...
...
@@ -14,4 +14,13 @@
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>
org.junit.jupiter
</groupId>
<artifactId>
junit-jupiter-api
</artifactId>
<version>
5.10.0
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
src/test/java/p08_funkcje/SilniaTest.java
0 → 100644
View file @
6fd161af
package
p08_funkcje
;
import
org.junit.jupiter.api.Test
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
class
SilniaTest
{
@Test
void
silnia
()
{
long
wynik
=
Silnia
.
silnia
(
5
);
// W języku Java (podobnie jak w Python) istnieje słowo kluczowe assert
// Gdy warunek jest prawdą → nic się nie dzieje, program idzie dalej
// Gdy warunek jest fałszywy → wyrzucany jest wyjątek AssertionError,
// a JUnit wyłapuje ten wyjątek i informuje, że test skończył się porażką.
// Tak pisany assert działa tylko w trybie testowania, a (gdyby wystąpił w normalnym kodzie),
// jest pomijany "na produkcji".
// assert wynik == 120;
// W testach zdecydowanie częściej używa się dedykowanych asercji, które dają bardziej precyzyjne komunikaty, co się nie zgadza.
// assertEquals(wartośćOczekiwana, wartośćFaktyczna)
// to najczęściej używany rodzaj asercji w bibliotece JUnit.
assertEquals
(
120
,
wynik
);
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment