## testing k complementary pairs algorithm with junit

This is the test class for the java solution of the k-complementary problem listed here

``````
package algorithm;

import static org.junit.Assert.assertArrayEquals;

import org.junit.Before;
import org.junit.Test;

/**
* Testing KComplementary algorithm
*
* @author Kaleb Woldearegay
*
*/
public class KComplementaryTest {

private KComplementary kComplementary;

@Before
public void initiate() {
this.kComplementary = new KComplementary();
}

@Test
public void test1() {
Integer[][] expectedResult = new Integer[][]{{1,9},{5,5},{9,1}};
int[] test = new int[]{1,5,9};

assertArrayEquals(this.kComplementary.getKComplementaryPairs(10,  test), expectedResult);
}

@Test
public void test2() {
Integer[][] expectedResult = new Integer[][]{{5,7},{7,5}};
int[] test = new int[]{3,5,7};

assertArrayEquals(this.kComplementary.getKComplementaryPairs(12,  test), expectedResult);
}

@Test
public void test3() {
Integer[][] expectedResult = new Integer[][]{{-1,1},{0,0},{1,-1}};
int[] test = new int[]{5,-1,0,-2,3, 1};

assertArrayEquals(this.kComplementary.getKComplementaryPairs(0,  test), expectedResult);
}

}
``````

See more algorithm solutions by clicking Here

## Running a single PhpUnit test

Well, we all love tests :). There are times we would like to run a single test that has failed so that we can fix or look at it thoroughly.
The problem, when you are running

```phpunit -c /testFolder..
```

All tests would run.
The fix..
Let’s assume you have this particular test in one of your test files

```public function testPhpIsAwesomeOrNot(){
}
```

All you have to do is to add the group annotation above the function

```
/**
* @group awesome
*/
public function testPhpIsAwesomeOrNot(){}
```

then run it with –group
like
phpunit -c /testfolder –group awesome