Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
Junit Assigments
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
Lakshmi Chaitanya
Junit Assigments
Commits
5d576b07
Commit
5d576b07
authored
Feb 17, 2022
by
Lakshmi Chaitanya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First commit
parents
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
207 additions
and
0 deletions
+207
-0
.gitignore
.idea/.gitignore
+3
-0
build.gradle
build.gradle
+27
-0
Employee.java
src/main/java/Employee.java
+97
-0
EmployeeMocitoTest.java
src/test/java/EmployeeMocitoTest.java
+29
-0
EmployeeTest.java
src/test/java/EmployeeTest.java
+44
-0
EmployeeTestData.csv
src/test/resources/EmployeeTestData.csv
+7
-0
No files found.
.idea/.gitignore
0 → 100644
View file @
5d576b07
# Default ignored files
/shelf/
/workspace.xml
build.gradle
0 → 100644
View file @
5d576b07
plugins
{
id
'java'
}
group
'org.example'
version
'1.0-SNAPSHOT'
repositories
{
mavenCentral
()
}
dependencies
{
testImplementation
group:
'org.junit.jupiter'
,
name:
'junit-jupiter-params'
,
version:
'5.8.2'
testRuntimeOnly
(
'org.junit.jupiter:junit-jupiter-params:5.8.2'
)
testImplementation
group:
'org.junit.jupiter'
,
name:
'junit-jupiter-api'
,
version:
'5.8.2'
testImplementation
'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly
'org.junit.jupiter:junit-jupiter-engine:5.8.2'
testImplementation
'org.mockito:mockito-core:4.3.1'
testImplementation
'org.mockito:mockito-junit-jupiter:4.3.1'
}
test
{
useJUnitPlatform
()
}
\ No newline at end of file
src/main/java/Employee.java
0 → 100644
View file @
5d576b07
public
class
Employee
{
private
String
firstName
;
private
String
lastName
;
private
String
dob
;
private
String
address1
;
private
String
address2
;
private
String
city
;
private
String
state
;
private
int
postalCode
;
public
Employee
(
String
firstName
,
String
lastName
,
String
dob
,
String
address1
,
String
address2
,
String
city
,
String
state
,
int
postalCode
)
{
this
.
firstName
=
firstName
;
this
.
lastName
=
lastName
;
this
.
dob
=
dob
;
this
.
address1
=
address1
;
this
.
address2
=
address2
;
this
.
city
=
city
;
this
.
state
=
state
;
this
.
postalCode
=
postalCode
;
}
public
Employee
()
{
}
public
Employee
addEmployee
()
{
return
new
Employee
(
"Lakshmi"
,
"chaitanya"
,
"08/10/1985"
,
"9400 w parmer"
,
"9401 w parmer"
,
"Austin"
,
"Tx"
,
73526
);
}
public
String
getFirstName
()
{
return
firstName
;
}
public
void
setFirstName
(
String
firstName
)
{
this
.
firstName
=
firstName
;
}
public
String
getLastName
()
{
return
lastName
;
}
public
void
setLastName
(
String
lastName
)
{
this
.
lastName
=
lastName
;
}
public
String
getDob
()
{
return
dob
;
}
public
void
setDob
(
String
dob
)
{
this
.
dob
=
dob
;
}
public
String
getAddress1
()
{
return
address1
;
}
public
void
setAddress1
(
String
address1
)
{
this
.
address1
=
address1
;
}
public
String
getAddress2
()
{
return
address2
;
}
public
void
setAddress2
(
String
address2
)
{
this
.
address2
=
address2
;
}
public
String
getCity
()
{
return
city
;
}
public
void
setCity
(
String
city
)
{
this
.
city
=
city
;
}
public
String
getState
()
{
return
state
;
}
public
void
setState
(
String
state
)
{
this
.
state
=
state
;
}
public
int
getPostalCode
()
{
return
postalCode
;
}
public
void
setPostalCode
(
int
postalCode
)
{
this
.
postalCode
=
postalCode
;
}
}
src/test/java/EmployeeMocitoTest.java
0 → 100644
View file @
5d576b07
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.mockito.Mock
;
import
org.mockito.junit.jupiter.MockitoExtension
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertNotEquals
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
when
;
@ExtendWith
(
MockitoExtension
.
class
)
public
class
EmployeeMocitoTest
{
@Mock
Employee
employee
;
@Test
void
testGetLastName
()
{
when
(
employee
.
getLastName
()).
thenReturn
(
"mockLastName"
);
assertEquals
(
"mockLastName"
,
employee
.
getLastName
());
}
@Test
void
testAddEmployee
()
{
when
(
employee
.
addEmployee
())
.
thenReturn
(
new
Employee
(
"pavani"
,
"ravuri"
,
"08/10/1985"
,
"9400 w parmer"
,
"9401 w parmer"
,
"Austin"
,
"Tx"
,
10000
));
assertNotEquals
(
73526
,
employee
.
addEmployee
().
getPostalCode
());
}
}
src/test/java/EmployeeTest.java
0 → 100644
View file @
5d576b07
import
org.junit.jupiter.api.Assertions
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.params.ParameterizedTest
;
import
org.junit.jupiter.params.provider.CsvFileSource
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
import
static
org
.
junit
.
jupiter
.
api
.
Assumptions
.
assumingThat
;
public
class
EmployeeTest
{
Employee
employee
=
null
;
@BeforeEach
void
setup
()
{
employee
=
new
Employee
();
}
@ParameterizedTest
@CsvFileSource
(
resources
=
"/EmployeeTestData.csv"
)
public
void
testGetFirstName
(
String
firstName
,
String
lastName
,
String
dob
,
String
addressLine1
,
String
addressLine2
,
String
city
,
String
state
,
int
postalCode
)
{
this
.
employee
=
new
Employee
(
firstName
,
lastName
,
dob
,
addressLine1
,
addressLine2
,
city
,
state
,
postalCode
);
assertAll
(
()
->
assertNotNull
(
employee
),
()
->
assertEquals
(
firstName
,
employee
.
getFirstName
()),
()
->
assertEquals
(
lastName
,
employee
.
getLastName
()),
()
->
assertEquals
(
dob
,
employee
.
getDob
()),
()
->
assertEquals
(
addressLine1
,
employee
.
getAddress1
()),
()
->
assertEquals
(
addressLine2
,
employee
.
getAddress2
()),
()
->
assertEquals
(
city
,
employee
.
getCity
()),
()
->
assertEquals
(
state
,
employee
.
getState
()),
()
->
assertEquals
(
postalCode
,
employee
.
getPostalCode
())
);
}
@Test
public
void
assumingThatEmployeeTest
()
{
assumingThat
(
employee
==
null
,
()
->
assertTrue
(
employee
.
getFirstName
()
!=
null
,
"assumingThatTest - Failed"
));
assertFalse
(
employee
.
getFirstName
()
!=
null
,
"assumingThatTest - Failed"
);
}
}
src/test/resources/EmployeeTestData.csv
0 → 100644
View file @
5d576b07
Lakshmi,chaitanya,08/10/1985,9400 w parmer,9401 w parmer, Austin,Tx,73526
pavani,ravuri,08/16/1982,9401 w parmer,9406 w parmer, San Ramon, Ca,73516
Suresh,nuthki,05/12/1987,9402 w parmer,9407 w parmer,Charlotte, Nc,73536
Kishore,rachagulla,04/16/1989,9403 w parmer,9408 w parmer, Denver, Co,73546
Revathi,venkata,08/10/1983,9404 w parmer,9409 w parmer, Dallas, Tx,73556
Saahithi,rachagulla,03/10/1988,9405 w parmer,9405 w parmer, San Antonio, Tx,73566
\ 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