This project shows a basic TDD example with some of the most common annotations.
This project used Java and Maven.
We have to declare the maven-surefire-plugin in the pom.xml file and configure the dependencies of this plugin.
We have to declare the following dependencies:
The junit-platform-surefire-provider dependency allows us to run tests that use either the “old” JUnit (3 or 4) or JUnit 5.
If we want to run tests that use either JUnit 3 or 4, we have to declare the junit-vintage-engine dependency.
If we want to run tests that use JUnit 5, we have to declare the junit-jupiter-engine dependency.
- Junit Jupiter Dependency graph
- JUnit Annotation
mvn clean test
mvn javadoc:javadoc
mvn javadoc:test-javadoc
mvn test jacoco:report
mvn test jacoco:check
mvn org.pitest:pitest-maven:mutationCoverage
mvn org.pitest:pitest-maven:mutationCoverage -DwithHistory
mvn test jacoco:report org.pitest:pitest-maven:mutationCoverage -DhistoryInputFile=target/fasterPitMutationTesting-history.txt -DhistoryOutputFile=target/fasterPitMutationTesting-history.txt -Dsonar.pitest.mode=reuseReport -Dthreads=4 -DtimestampedReports=false
- https://github.com/pitest/pitest-junit5-plugin
- https://mvnrepository.com/artifact/org.pitest/pitest-junit5-plugin
- required to work with JUnit5
- https://mvnrepository.com/artifact/org.pitest/pitest-junit5-plugin
- count secure URLs
- associate bookmarks from same domain
- filter bookmarks by one keyword
- filter bookmarks by one or more keywords
- remove TAG from bookmark
- remove URL bm
- add current date/time when adding bm
- sort bm by rating desc
- sort bm by date desc
- Are we allowed to break the 1 test per commit rule, if our method breaks other tests?
- How to handle void functions (Mutation testing)?
- addKeywordToUrl Case 8: Check if keyword was added
- addBookmark Case 5: Check size of Bookmarklist
- Case 1: has secure URLs -> return count
- Case 2: No secure URLs -> return 0
- Case 3: List empty -> return -1
- Case 1: keyword is NULL -> return NULL
- Case 2: bms found -> return List
- Case 3: no bms found -> return emptyList
- Case 4: List is empty -> return NULL
- Case 5: check Case Sensitivity
- Case 1: bookmarks for all keywords found -> return all found
- Case 2: keywords are empty -> return NULL
- Case 3: keywords are NULL -> return NULL
- Case 4: bms for some keywords found, but not for others -> return List for all found bms
- Case 1: url is a URL, -> correct domain set
- Case 2: url is NULL -> domain is NULL
- Case 3: url is invalid -> domain is NULL
- Case 1: domain is NULL -> null
- Case 2: no bms found -> emptyList()
- Case 3: bms found -> List
- Case 4: bms found -> List correct size?
- Case 5: bmList empty -> emptyList()
Case 1: Is Duplicate
Bookmark List contains: "https://www.google.com"
new Bookmark URL = "https://www.google.com"
expected: false
Case 2: Is not Duplicate
Bookmark List does not contain: "https://www.google.com"
new Bookmark URL = "https://www.google.com"
expected: true
Case 3: Is NULL
URL = NULL
expected false
Case 1: URL is not valid
URL = "hello, world!"
expected: false
Case 2: URL is valid
URL = "https://www.google.com"
expected: true
Case 3: String is NULL
URL = null
expected: false
Case 1: is successful
Bookmarklist contains URL
URL = "https://github.com/"
keyword = "programming"
expected: true
Case 2: URL does not exist in Bookmarklist
Bookmarklist does not contain URL
URL = "https://github.com/"
keyword = "programming"
expected: false
Case 3: Keyword is NULL
Bookmarklist contains URL
URL = "https://github.com/"
keyword = NULL
expected: false
Case 4: URL is NULL
Bookmarklist contains URL
URL = NULL
keyword = "programming"
expected: false
Case 5: Keyword and URL is NULL
Bookmarklist contains URL
URL = NULL
keyword = NULL
expected: true
Case 6: Bookmark has already associated Keyword
Bookmarklist contains URL with keyword "work"
URL = "https://github.com/"
keyword = "programming"
expected: true
Case 7: Testing Case Sensitivity
Bookmarklist contains URL with keyword "Programming"
URL = "https://github.com/"
keyword = "programming"
expected: true
Case 1: URL does not already exist, is successful
Bookmarklist does not contain URL
URL = "https://github.com/"
expected: "https://github.com/"
Case 2: URL already exists
Bookmarklist does contain URL
URL = "https://github.com/"
(increases rating)
expected: 2
Case 3: URL is NULL
Bookmarklist does not contain URL
URL = NULL
expected: NULL
Case 4: URL is invalid
Bookmarklist does not contain URL
URL = "hello, world!"
expected: NULL
#Testcases Calculator
Case 1: positive + positive
4 + 3
expected: 7
Case 2: positive + negative
4 + -3
expected: 1
Case 3: negative + positive
-4 + 3
expected: -1
Case 4: negative + negative
-4 + -3
expected: -7
Case 5: positive + 0
4 + 0
expected: 4
Case 6: 0 + positive
0 + 3
expected: 3
Case 7: negative + 0
-4 + 0
expected: -4
Case 8: 0 + negative
0 + -3
expected: -3
Case 1: positive - positive
4 - 3
expected: 1
Case 2: positive - negative
4 - -3
expected: 7
Case 3: negative - positive
-4 - 3
expected: -7
Case 4: negative - negative
-4 - -3
expected: -1
Case 5: positive - 0
4 - 0
expected: 4
Case 6: 0 - positive
0 - 3
expected: -3
Case 7: negative - 0
-4 - 0
expected: -4
Case 8: 0 - negative
0 - -3
expected: 3
Case 1: positive * positive
4 * 3
expected: 12
Case 2: positive * negative
4 * -3
expected: -12
Case 3: negative * positive
-4 * 3
expected: -12
Case 4: negative * negative
-4 * -3
expected: 12
Case 5: positive * 0
4 * 0
expected: 0
Case 6: 0 * positive
0 * 3
expected: 0
Case 7: negative * 0
-4 * 0
expected: 0
Case 8: 0 * negative
0 * -3
expected: 0
Case 1: positive / positive
8 / 3
expected: 2
Case 2: positive / negative
8 / -3
expected: -2
Case 3: negative / positive
-8 / 3
expected: -2
Case 4: negative / negative
-8 / -3
expected: 2
Case 5: positive / 0
8 / 0
expected: error
Case 6: 0 / positive
0 / 3
expected: 0
Case 7: negative / 0
-8 / 0
expected: error
Case 8: 0 / negative
0 / -3
expected: 0
Case 1: positive
3!
expected: 6
Case 2: negative
-3!
expected: 1
Case 3: 0
0!
expected: 1