Skip to content

Anych/test-factorial-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Test Factorial

This exercise is about getting familiar with unit testing and JUnit 5 approach in particular.

  1. Design and code a factorial method in the Factorial class. Here are some details:
  • the method takes a String as a parameter, transforms it to an integer value and counts its factorial.
  • The method returns a result as a String.
  • String parameter n must represent a non-negative integer number. If it does not, throw an IllegalArgumentException.
  1. Complete the test classes:
  • FactorialBadInputTesting
    There are four empty methods that you must complete:
    • testNullInput - test a null input cases
    • testNegativeInput - test a negative number input cases
    • testFractionalInput - test a fractional cases
    • testNonDigitalInput - test a non-digit cases
  • FactorialCsvParametrizedTesting
    it is a parameterized test, that takes arguments from the csvCases.csv file. Do not change the csv file, only implement the method.
  • FactorialMethodSourceParametrizedTesting
    it is a parameterized test, that takes arguments from the testCases method. You must complete the test method and introduce the testCases method, that provides following cases:
    • "1", "1"
    • "2", "2"
    • "5", "120"
  • FactorialRegularInputTesting
    it is a test class where you can add regular test cases. Consider covering cases that are not present in other test classes.

To pass the exercise, your tests must correctly detect flaws of some other implementations. There are special tests in several classes that apply your tests to your and other problematic("bad") implementations:

Your solution method must pass your tests while other implementation must fail your tests in some cases.

Also, there is one more secret test class that you do not have access to. It will be applied to your solution once you submit it to Autocode. So, consider the variety of possible cases.

Hint: Factorial reference

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages