Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setup methods with @BeforeClass is better for initialization #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,30 @@
* @version 1.0
* @since 2018-04-11
*/

import org.junit.BeforeClass;
import org.junit.Before;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.Rule;
import org.junit.Assert;
import static org.junit.Assert.*;

public class MyFileUtilitiesTest {

//Declaring the expected array
int array[];
//Creating a MyFileUtilities object
MyFileUtilities mfu = new MyFileUtilities();
MyFileUtilities mfu ;

/*
* Initializes the integer
* array, assigning it the
* expected values.
*/
@Before
public void initializeArray() {
@BeforeClass
public static void setup(){

array = new int[] {5, 10, 2, 3, 1, 4, 6, 3, 1, 7, 4};

mfu = new MyFileUtilities();
}

/*
Expand All @@ -45,7 +45,7 @@ public void initializeArray() {
@Test
public void normal_case() {

Assert.assertArrayEquals(array, mfu.readFile("src/test/resources/grades"));
assertArrayEquals(array, mfu.readFile("src/test/resources/grades"));

}

Expand Down