Kumite (ko͞omiˌtā) is the practice of taking techniques learned from Kata and applying them through the act of freestyle sparring.
You can create a new kumite by providing some initial code and optionally some test cases. From there other warriors can spar with you, by enhancing, refactoring and translating your code. There is no limit to how many warriors you can spar with.
A great use for kumite is to begin an idea for a kata as one. You can collaborate with other code warriors until you have it right, then you can convert it to a kata.
I created a single parameterized test to avoid redundant tests for the same output function without additional logic.
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import java.util.stream.Stream; import static org.assertj.core.api.Assertions.assertThat; class SolutionTest { @ParameterizedTest @MethodSource("testCases") public void it_should_return_the_expected_value_for_test_case(String inputName, String expectedOutputValue) { assertThat(greet.greet(inputName)) .as("It should return the expected value for %s", inputName) .isEqualTo(expectedOutputValue); } public static Stream<Arguments> testCases() { return Stream.of( Arguments.of("Reemu", "hello my name is Reemu"), Arguments.of("Pepo", "hello my name is Pepo"), Arguments.of("Delacroix", "hello my name is Delacroix"), Arguments.of("Toto", "hello my name is Toto") ); } private final Greet greet = new Greet(); }
import org.junit.jupiter.api.Test;import static org.junit.jupiter.api.Assertions.assertEquals;- import org.junit.jupiter.params.ParameterizedTest;
- import org.junit.jupiter.params.provider.Arguments;
- import org.junit.jupiter.params.provider.MethodSource;
- import java.util.stream.Stream;
- import static org.assertj.core.api.Assertions.assertThat;
// TODO: Replace examples and use TDD by writing your own tests- class SolutionTest {
@Testvoid testSomething() {assertEquals("hello my name is Reemu", new Greet().greet("Reemu"));- @ParameterizedTest
- @MethodSource("testCases")
- public void it_should_return_the_expected_value_for_test_case(String inputName, String expectedOutputValue) {
- assertThat(greet.greet(inputName))
- .as("It should return the expected value for %s", inputName)
- .isEqualTo(expectedOutputValue);
- }
- public static Stream<Arguments> testCases() {
- return Stream.of(
- Arguments.of("Reemu", "hello my name is Reemu"),
- Arguments.of("Pepo", "hello my name is Pepo"),
- Arguments.of("Delacroix", "hello my name is Delacroix"),
- Arguments.of("Toto", "hello my name is Toto")
- );
- }
- private final Greet greet = new Greet();
- }
def best_moves(score) # return the three best moves to reach 0 from the given score if (score.is_even && score <= 40) || score == 50 do return [score] end if score >= 182 do return [60, 60, 60] end if score == 21 do end end
- def best_moves(score)
- # return the three best moves to reach 0 from the given score
- if (score.is_even && score <= 40) || score == 50 do
- return [score]
- end
- if score >= 182 do
- return [60, 60, 60]
- end
- if score == 21 do
- end
- end
# From Ruby 3.0, RSpec is used under the hood. # See https://rspec.info/ # Defaults to the global `describe` for backwards compatibility, but `RSpec.desribe` works as well. describe "Example" do it "should return the optimal moves" do expect(best_moves(301)).to eq([60,60,60]) expect(best_moves(170)).to eq([60,60,50]) expect(best_moves(141)).to eq([60,57,24]) expect(best_moves(141).last).to be_even # expect(best_moves(5)).to needs to be either [1,4] or [1,2,2] end it "" do end end
- # From Ruby 3.0, RSpec is used under the hood.
- # See https://rspec.info/
- # Defaults to the global `describe` for backwards compatibility, but `RSpec.desribe` works as well.
- describe "Example" do
- it "should return the optimal moves" do
- expect(best_moves(301)).to eq([60,60,60])
- expect(best_moves(170)).to eq([60,60,50])
- expect(best_moves(141)).to eq([60,57,24])
expect(best_moves(141).last.even?).to be_true- expect(best_moves(141).last).to be_even
- # expect(best_moves(5)).to needs to be either [1,4] or [1,2,2]
# The following is still supported, but new tests should now use them.# Test.assert_equals(add(1, 1), 2)- end
- it "" do
- end
- end