Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
junit-exercise
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
Shanelle Valencia
junit-exercise
Commits
4deb3327
Commit
4deb3327
authored
Apr 12, 2021
by
Shanelle Valencia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more tests
parent
e4882a87
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
3 deletions
+53
-3
vcs.xml
.idea/vcs.xml
+6
-0
CalculatorTest.java
src/test/java/com/myapp/CalculatorTest.java
+16
-0
StringsTest.java
src/test/java/com/myapp/StringsTest.java
+31
-3
CalculatorTest.class
target/test-classes/com/myapp/CalculatorTest.class
+0
-0
StringsTest.class
target/test-classes/com/myapp/StringsTest.class
+0
-0
No files found.
.idea/vcs.xml
0 → 100644
View file @
4deb3327
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"VcsDirectoryMappings"
>
<mapping
directory=
"$PROJECT_DIR$"
vcs=
"Git"
/>
</component>
</project>
\ No newline at end of file
src/test/java/com/myapp/CalculatorTest.java
View file @
4deb3327
...
...
@@ -32,4 +32,20 @@ public class CalculatorTest {
Assert
.
assertEquals
(
res
,
30
);
}
@Test
public
void
assertNotNull
()
{
Calculator
calc
=
new
Calculator
();
Assert
.
assertNotNull
(
calc
);
}
@Test
public
void
assertNull
()
{
Calculator
calc
=
new
Calculator
();
Assert
.
assertNull
(
"Failed: Not Null"
,
calc
);
}
}
src/test/java/com/myapp/StringsTest.java
View file @
4deb3327
...
...
@@ -11,6 +11,8 @@ import java.util.List;
public
class
StringsTest
{
String
string
;
@Before
public
void
beforeTest
()
{
...
...
@@ -46,13 +48,39 @@ public class StringsTest {
@Test
public
void
testEvenWordsInSent
()
{
List
<
String
>
evens
=
new
Strings
().
evenWordsInSent
(
"This is a sentence with even and odd words"
);
List
<
String
>
actual
=
Arrays
.
asList
(
"This"
,
"is"
,
"sentence"
,
"with"
,
"even"
);
String
sentence
=
"This is a sentence with even and odd words"
;
List
<
String
>
expected
=
new
Strings
().
evenWordsInSent
(
sentence
);
List
<
String
>
actual
=
Arrays
.
asList
(
sentence
.
split
(
" "
));
// List<String> actual = Arrays.asList("This", "is", "sentence", "with", "even");
// Assert.assertEquals("Failed", expected, actual);
Assert
.
assertNotEquals
(
expected
,
actual
);
}
@Test
public
void
assertNotEquals
()
{
String
sentence
=
"This is a sentence with even and odd words"
;
List
<
String
>
expected
=
new
Strings
().
evenWordsInSent
(
sentence
);
List
<
String
>
actual
=
Arrays
.
asList
(
sentence
.
split
(
" "
));
Assert
.
assert
Equals
(
evens
,
actual
);
Assert
.
assert
NotEquals
(
expected
,
actual
);
}
@Test
public
void
assertNotSame
()
{
String
sentence
=
"This is a sentence with even and odd words"
;
List
<
String
>
expected
=
new
Strings
().
evenWordsInSent
(
sentence
);
List
<
String
>
actual
=
Arrays
.
asList
(
sentence
.
split
(
" "
));
Assert
.
assertNotSame
(
"Failed: expected and actual are the same"
,
expected
,
actual
);
}
@AfterClass
//must be static bc its a class method
public
static
void
afterClass
()
{
...
...
target/test-classes/com/myapp/CalculatorTest.class
View file @
4deb3327
No preview for this file type
target/test-classes/com/myapp/StringsTest.class
View file @
4deb3327
No preview for this file type
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