Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
JunitExample
Project
Project
Details
Activity
Releases
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
Alex Pinto
JunitExample
Commits
ccbb398d
Commit
ccbb398d
authored
Apr 08, 2021
by
Alex Pinto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial commit
parents
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
83 additions
and
0 deletions
+83
-0
JUnitExample.iml
JUnitExample.iml
+3
-0
pom.xml
pom.xml
+25
-0
Calculator.java
src/main/java/my/com/Calculator.java
+15
-0
CalculatorTest.java
src/test/java/CalculatorTest.java
+26
-0
TestRunner.java
src/test/java/TestRunner.java
+14
-0
Calculator.class
target/classes/my/com/Calculator.class
+0
-0
CalculatorTest.class
target/test-classes/CalculatorTest.class
+0
-0
TestRunner.class
target/test-classes/TestRunner.class
+0
-0
No files found.
JUnitExample.iml
0 → 100644
View file @
ccbb398d
<?xml version="1.0" encoding="UTF-8"?>
<module
type=
"JAVA_MODULE"
version=
"4"
/>
\ No newline at end of file
pom.xml
0 → 100644
View file @
ccbb398d
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
org.example
</groupId>
<artifactId>
JUnitExample
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<dependencies>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
4.13
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>
15
</maven.compiler.source>
<maven.compiler.target>
15
</maven.compiler.target>
</properties>
</project>
\ No newline at end of file
src/main/java/my/com/Calculator.java
0 → 100644
View file @
ccbb398d
package
my
.
com
;
public
class
Calculator
{
public
int
add
(
int
x
,
int
y
)
{
return
x
+
y
;
}
public
int
subtract
(
int
x
,
int
y
)
{
return
x
-
y
;
}
public
int
multiply
(
int
x
,
int
y
)
{
return
x
*
y
;
}
}
src/test/java/CalculatorTest.java
0 → 100644
View file @
ccbb398d
import
my.com.Calculator
;
import
org.junit.Test
;
import
org.junit.Assert
;
public
class
CalculatorTest
{
@Test
public
void
addTest
()
{
int
sum
=
new
Calculator
().
add
(
3
,
4
);
Assert
.
assertTrue
(
"Failed"
,
sum
==
7
);
}
@Test
public
void
subTest
()
{
int
result
=
new
Calculator
().
subtract
(
4
,
3
);
Assert
.
assertEquals
(
result
,
1
);
}
@Test
public
void
mulTest
()
{
int
result
=
new
Calculator
().
multiply
(
4
,
3
);
Assert
.
assertEquals
(
result
,
12
);
}
}
src/test/java/TestRunner.java
0 → 100644
View file @
ccbb398d
import
org.junit.runner.JUnitCore
;
import
org.junit.runner.Result
;
import
org.junit.runner.notification.Failure
;
public
class
TestRunner
{
public
static
void
main
(
String
[]
args
)
{
Result
result
=
JUnitCore
.
runClasses
(
CalculatorTest
.
class
);
for
(
Failure
failure
:
result
.
getFailures
())
{
System
.
out
.
println
(
failure
.
toString
());
}
System
.
out
.
println
(
"Failure count: "
+
result
.
getFailureCount
());
}
}
target/classes/my/com/Calculator.class
0 → 100644
View file @
ccbb398d
File added
target/test-classes/CalculatorTest.class
0 → 100644
View file @
ccbb398d
File added
target/test-classes/TestRunner.class
0 → 100644
View file @
ccbb398d
File added
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