Skip to content

Commit 45e3082

Browse files
author
jantje
committed
renaming tests to surefire convention
Also moved the build code to shared
1 parent 2947fe2 commit 45e3082

7 files changed

+52
-52
lines changed

io.sloeber.tests/src/io/sloeber/core/CompileAndUpload.java renamed to io.sloeber.tests/src/io/sloeber/core/CompileAndUploadTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@
4343

4444
@SuppressWarnings("nls")
4545
@RunWith(Parameterized.class)
46-
public class CompileAndUpload {
46+
public class CompileAndUploadTest {
4747
private static final boolean reinstall_boards_and_libraries = false;
4848
private static int mCounter = 0;
4949
private IBoard myBoard;
5050
private String myName;
5151
private static String interval = "1500";// change between 1500 and 100
5252

53-
public CompileAndUpload(String name, IBoard board) {
53+
public CompileAndUploadTest(String name, IBoard board) {
5454
this.myBoard = board;
5555
this.myName = name;
5656

io.sloeber.tests/src/io/sloeber/core/CreateAndCompileArduinoIDEExamplesOnAVRHardware.java renamed to io.sloeber.tests/src/io/sloeber/core/CreateAndCompileArduinoIDEExamplesOnAVRHardwareTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
@SuppressWarnings("nls")
3838
@RunWith(Parameterized.class)
39-
public class CreateAndCompileArduinoIDEExamplesOnAVRHardware {
39+
public class CreateAndCompileArduinoIDEExamplesOnAVRHardwareTest {
4040
private static int mCounter = 0;
4141
private CodeDescriptor myCodeDescriptor;
4242
private String myName;
@@ -45,7 +45,7 @@ public class CreateAndCompileArduinoIDEExamplesOnAVRHardware {
4545
private boolean myUsesSerial;
4646
private static int totalFails = 0;
4747

48-
public CreateAndCompileArduinoIDEExamplesOnAVRHardware(String name, CodeDescriptor codeDescriptor,
48+
public CreateAndCompileArduinoIDEExamplesOnAVRHardwareTest(String name, CodeDescriptor codeDescriptor,
4949
boolean usesSerial, boolean usesSerial1, boolean usesKeyboard) {
5050

5151
this.myCodeDescriptor = codeDescriptor;

io.sloeber.tests/src/io/sloeber/core/CreateAndCompileArduinoIDEExamplesOnTeensy.java renamed to io.sloeber.tests/src/io/sloeber/core/CreateAndCompileArduinoIDEExamplesOnTeensyTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
@SuppressWarnings("nls")
3131
@RunWith(Parameterized.class)
32-
public class CreateAndCompileArduinoIDEExamplesOnTeensy {
32+
public class CreateAndCompileArduinoIDEExamplesOnTeensyTest {
3333
private static int mCounter = 0;
3434
private CodeDescriptor myCodeDescriptor;
3535
private String myName;
@@ -38,7 +38,7 @@ public class CreateAndCompileArduinoIDEExamplesOnTeensy {
3838
private boolean myUsesSerial;
3939
private static int totalFails = 0;
4040

41-
public CreateAndCompileArduinoIDEExamplesOnTeensy(String name, CodeDescriptor codeDescriptor,
41+
public CreateAndCompileArduinoIDEExamplesOnTeensyTest(String name, CodeDescriptor codeDescriptor,
4242
boolean usesSerial, boolean usesSerial1, boolean usesKeyboard) {
4343

4444
this.myCodeDescriptor = codeDescriptor;

io.sloeber.tests/src/io/sloeber/core/CreateAndCompileExamples.java renamed to io.sloeber.tests/src/io/sloeber/core/CreateAndCompileExamplesTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@
4343

4444
@SuppressWarnings("nls")
4545
@RunWith(Parameterized.class)
46-
public class CreateAndCompileExamples {
46+
public class CreateAndCompileExamplesTest {
4747
private static final boolean reinstall_boards_and_examples = false;
4848
private static int mCounter = 0;
4949
private CodeDescriptor myCodeDescriptor;
5050
private BoardDescriptor myBoardid;
5151
private static int totalFails = 0;
5252
private String myName;
5353

54-
public CreateAndCompileExamples(String name, BoardDescriptor boardid, CodeDescriptor codeDescriptor) {
54+
public CreateAndCompileExamplesTest(String name, BoardDescriptor boardid, CodeDescriptor codeDescriptor) {
5555
this.myBoardid = boardid;
5656
this.myCodeDescriptor = codeDescriptor;
5757
this.myName = name;

io.sloeber.tests/src/io/sloeber/core/CreateAndCompile.java renamed to io.sloeber.tests/src/io/sloeber/core/CreateAndCompileTest.java

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,30 @@
11
package io.sloeber.core;
22

3-
import static org.junit.Assert.fail;
4-
53
import java.io.File;
64
import java.util.ArrayList;
75
import java.util.Arrays;
86
import java.util.Collection;
97
import java.util.HashSet;
108
import java.util.List;
119

12-
import org.eclipse.core.resources.IProject;
13-
import org.eclipse.core.resources.IncrementalProjectBuilder;
14-
import org.eclipse.core.runtime.CoreException;
15-
import org.eclipse.core.runtime.NullProgressMonitor;
1610
import org.junit.Test;
1711
import org.junit.runner.RunWith;
1812
import org.junit.runners.Parameterized;
1913
import org.junit.runners.Parameterized.Parameters;
2014

2115
import io.sloeber.core.api.BoardDescriptor;
2216
import io.sloeber.core.api.BoardsManager;
23-
import io.sloeber.core.api.CodeDescriptor;
24-
import io.sloeber.core.api.CompileOptions;
25-
import io.sloeber.core.api.ConfigurationDescriptor;
2617
import io.sloeber.core.api.Preferences;
2718

2819
@SuppressWarnings("nls")
2920
@RunWith(Parameterized.class)
30-
public class CreateAndCompile {
21+
public class CreateAndCompileTest {
3122
// use the boolean below to avoid downloading and installation
3223
private static final boolean reinstall_boards_and_libraries = true;
3324
private BoardDescriptor mBoard;
34-
private static int mCounter = 0;
3525

36-
public CreateAndCompile(BoardDescriptor board) {
26+
27+
public CreateAndCompileTest(BoardDescriptor board) {
3728
this.mBoard = board;
3829
}
3930

@@ -152,40 +143,10 @@ public static void installAdditionalBoards() {
152143

153144
@Test
154145
public void testBoard() {
155-
BuildAndVerify(this.mBoard);
146+
Shared.BuildAndVerify(this.mBoard);
156147

157148
}
158149

159-
public static void BuildAndVerify(BoardDescriptor boardid) {
160150

161-
IProject theTestProject = null;
162-
CodeDescriptor codeDescriptor = CodeDescriptor.createDefaultIno();
163-
NullProgressMonitor monitor = new NullProgressMonitor();
164-
String projectName = String.format("%03d_", new Integer(mCounter++)) + boardid.getBoardID();
165-
try {
166-
167-
theTestProject = boardid.createProject(projectName, null, ConfigurationDescriptor.getDefaultDescriptors(),
168-
codeDescriptor, new CompileOptions(null), monitor);
169-
Shared.waitForAllJobsToFinish(); // for the indexer
170-
} catch (Exception e) {
171-
e.printStackTrace();
172-
fail("Failed to create the project:" + projectName);
173-
return;
174-
}
175-
try {
176-
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
177-
if (Shared.hasBuildErrors(theTestProject)) {
178-
fail("Failed to compile the project:" + projectName + " build errors");
179-
}
180-
} catch (CoreException e) {
181-
e.printStackTrace();
182-
fail("Failed to compile the project:" + boardid.getBoardName() + " exception");
183-
}
184-
try {
185-
theTestProject.delete(false, true, null);
186-
} catch (CoreException e) {
187-
e.printStackTrace();
188-
}
189-
}
190151

191152
}

io.sloeber.tests/src/io/sloeber/core/RegressionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void redirectedJson() {
6565
fail("redirect Json ");
6666
return;
6767
}
68-
CreateAndCompile.BuildAndVerify(boardid);
68+
Shared.BuildAndVerify(boardid);
6969
}
7070

7171
/**

io.sloeber.tests/src/io/sloeber/core/Shared.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,22 @@
1010
import org.eclipse.core.resources.IMarker;
1111
import org.eclipse.core.resources.IProject;
1212
import org.eclipse.core.resources.IResource;
13+
import org.eclipse.core.resources.IncrementalProjectBuilder;
1314
import org.eclipse.core.runtime.CoreException;
1415
import org.eclipse.core.runtime.FileLocator;
1516
import org.eclipse.core.runtime.IPath;
17+
import org.eclipse.core.runtime.NullProgressMonitor;
1618
import org.eclipse.core.runtime.Path;
1719
import org.eclipse.core.runtime.Platform;
1820
import org.eclipse.core.runtime.jobs.IJobManager;
1921
import org.eclipse.core.runtime.jobs.Job;
2022
import org.osgi.framework.Bundle;
2123

24+
import io.sloeber.core.api.BoardDescriptor;
2225
import io.sloeber.core.api.BoardsManager;
26+
import io.sloeber.core.api.CodeDescriptor;
27+
import io.sloeber.core.api.CompileOptions;
28+
import io.sloeber.core.api.ConfigurationDescriptor;
2329
import io.sloeber.core.api.Other;
2430

2531
@SuppressWarnings("nls")
@@ -30,6 +36,7 @@ public class Shared {
3036

3137
private static String jantjesWindowsMachine = "D:\\arduino\\arduino-1.8.2Teensy1.38beta2\\hardware\\teensy";
3238
private static String jantjesVirtualLinuxMachine = "/home/jantje/programs/arduino-1.8.0/hardware/teensy";
39+
private static int mCounter = 0;
3340

3441
public static String getTeensyPlatform() {
3542
switch (Other.getSystemHash()) {
@@ -93,4 +100,36 @@ public static IPath getTemplateFolder(String templateName) {
93100
return new Path(new String());
94101
}
95102

103+
public static void BuildAndVerify(BoardDescriptor boardid) {
104+
105+
IProject theTestProject = null;
106+
CodeDescriptor codeDescriptor = CodeDescriptor.createDefaultIno();
107+
NullProgressMonitor monitor = new NullProgressMonitor();
108+
String projectName = String.format("%03d_", new Integer(mCounter++)) + boardid.getBoardID();
109+
try {
110+
111+
theTestProject = boardid.createProject(projectName, null, ConfigurationDescriptor.getDefaultDescriptors(),
112+
codeDescriptor, new CompileOptions(null), monitor);
113+
Shared.waitForAllJobsToFinish(); // for the indexer
114+
} catch (Exception e) {
115+
e.printStackTrace();
116+
fail("Failed to create the project:" + projectName);
117+
return;
118+
}
119+
try {
120+
theTestProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
121+
if (Shared.hasBuildErrors(theTestProject)) {
122+
fail("Failed to compile the project:" + projectName + " build errors");
123+
}
124+
} catch (CoreException e) {
125+
e.printStackTrace();
126+
fail("Failed to compile the project:" + boardid.getBoardName() + " exception");
127+
}
128+
try {
129+
theTestProject.delete(false, true, null);
130+
} catch (CoreException e) {
131+
e.printStackTrace();
132+
}
133+
}
134+
96135
}

0 commit comments

Comments
 (0)