Skip to content

Commit d2921d9

Browse files
committed
Fix most of setup
* Add source files * Update README with badge links * Upload single test suite results file
1 parent 9446e45 commit d2921d9

File tree

11 files changed

+579
-24
lines changed

11 files changed

+579
-24
lines changed

.testspace.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<root>
44
<attributes>
55
<![CDATA[INSTALL_DIR = $PWD
6-
RESULTS_DIR = ${INSTALL_DIR}/target/surefire-reports/junitreports
6+
RESULTS_DIR = ${INSTALL_DIR}/target/surefire-reports
77
COVERAGE_DIR = ${INSTALL_DIR}/target/site/cobertura]]>
88
</attributes>
99
<suite name="Compile" state="1" id=".sh" description="**Compiling** Classes">
@@ -15,7 +15,7 @@ mvn clean compile]]>
1515
<suite name="Tests" state="1" id=".sh" description="run **all** of the tests">
1616
<attributes>
1717
<![CDATA[mvn cobertura:cobertura -Dcobertura.report.format=xml
18-
echo "${RESULTS_DIR}/TEST-*.xml{src/test/java/com/testspace/java}" > ${self.result}]]>
18+
echo "${RESULTS_DIR}/TEST-TestSuite.xml" > ${self.result}]]>
1919
</attributes>
2020
</suite>
2121
<suite name="Coverage" state="1" id=".sh" description="Code coverage based on latest run. Review the ==Reports== tab for historical tracking">

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ language:
44
before_install:
55
# Install Testspace Runner
66
- ./testspace_install.sh
7+
- export PATH="${HOME}/testspace:${PATH}"
78

89
script:
910
- mvn clean compile
1011
- mvn cobertura:cobertura -Dcobertura.report.format=xml
1112

12-
# Publish Test Results along with Coverage
13-
- export PATH="${HOME}/testspace:${PATH}"
1413
# Testspace credentials: "[email protected]/myproject/myspace
1514
- testspace config url ${TESTSPACE_USER_TOKEN}:@${TESTSPACE_URL}
16-
- testspace publish [Tests]./target/surefire-reports/junitreports/TEST*.xml{src/test/java/com/testspace/java} ./target/site/cobertura/coverage.xml
15+
# Publish Test Results along with Coverage
16+
- testspace publish target/surefire-reports/TEST-TestSuite.xml target/site/cobertura/coverage.xml

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Sample demonstrates techniques for using Testspace with Java code and the [TestN
88
***
99

1010
[![Build Status](https://travis-ci.org/testspace-samples/java.testng.svg?branch=master)](https://travis-ci.org/testspace-samples/java.testng)
11-
[![Space Health](https://samples.testspace.com/projects/84/spaces/285/badge)](https://samples.testspace.com/projects/84/spaces/285 "Test Cases")
12-
[![Space Metric](https://samples.testspace.com/projects/84/spaces/285/metrics/179/badge)](https://samples.testspace.com/projects/84/spaces/285/metrics#metric-179 "Line/Statement Coverage")
11+
[![Space Health](https://samples.testspace.com/projects/88/spaces/325/badge)](https://samples.testspace.com/projects/88/spaces/325 "Test Cases")
12+
[![Space Metric](https://samples.testspace.com/projects/88/spaces/325/metrics/228/badge)](https://samples.testspace.com/projects/88/spaces/325/metrics#metric-228 "Line/Statement Coverage")
1313

1414
***
1515

@@ -20,10 +20,10 @@ Build examples:
2020
mvn cobertura:cobertura -Dcobertura.report.format=xml
2121
</pre>
2222

23-
Publish **`test results`** along with **`code coverage`**
23+
Publishing results example:
2424

2525
<pre>
26-
testspace publish ./target/surefire-reports/junitreports/TEST*.xml ./target/site/cobertura/coverage.xml results
26+
testspace publish target/surefire-reports/TEST-TestSuite.xml target/site/cobertura/coverage.xml
2727
</pre>
2828

2929
Checkout the [Space](https://samples.testspace.com/projects/java/spaces/testng).
@@ -34,4 +34,4 @@ To fork this example using Travis requires:
3434
- Create an account at www.testspace.com
3535
- Travis Environment Variables:
3636
- `TESTSPACE_USER_TOKEN` set to the `value` defined as your [Access token](http://help.testspace.com/using-your-organization:user-settings).
37-
- `TESTSPACE_URL` set to `my-org-name.testspace.com/my-project/my-space`. Refer [here](http://help.testspace.com/reference:runner-reference#config) for more details. This example uses `samples.testspace.com/cpp/googletest`.
37+
- `TESTSPACE_URL` set to `my-org-name.testspace.com/my-project/my-space`. Refer [here](http://help.testspace.com/reference:runner-reference#config) for more details.

pom.xml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@
1717
</dependencies>
1818
<reporting>
1919
<plugins>
20-
<!-- integrate maven-cobertura-plugin to project site -->
21-
<plugin>
22-
<groupId>org.codehaus.mojo</groupId>
23-
<artifactId>cobertura-maven-plugin</artifactId>
24-
<version>2.6</version>
25-
<configuration>
26-
<formats>
27-
<format>html</format>
28-
<format>xml</format>
29-
</formats>
30-
</configuration>
31-
</plugin>
20+
<!-- integrate maven-cobertura-plugin to project site -->
21+
<plugin>
22+
<groupId>org.codehaus.mojo</groupId>
23+
<artifactId>cobertura-maven-plugin</artifactId>
24+
<version>2.6</version>
25+
<configuration>
26+
<formats>
27+
<format>html</format>
28+
<format>xml</format>
29+
</formats>
30+
</configuration>
31+
</plugin>
3232
</plugins>
3333
</reporting>
3434
<build>

shippable.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ env:
66

77
before_script:
88
- ./testspace_install.sh
9+
- export PATH="${HOME}/testspace:${PATH}"
910
- mkdir -p shippable/codecoverage
1011
- mkdir -p shippable/testresults
1112

1213
script:
13-
- export PATH="${HOME}/testspace:${PATH}"
1414
- testspace config url $TESTSPACE_TOKEN
1515
- testspace import .testspace.xml
1616
- testspace run
1717

18-
- cp target/surefire-reports/junitreports/TEST*.xml shippable/testresults
18+
after_script:
19+
- cp target/surefire-reports/TEST-TestSuite.xml shippable/testresults
1920
- cp target/site/cobertura/coverage.xml shippable/codecoverage
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
package com.testspace.java.list;
2+
3+
/**
4+
* A class to provide a simple list.
5+
* List resizes automatically. Used to illustrate
6+
* various design and implementation details of
7+
* a class in Java.
8+
*
9+
* @author scottm
10+
*
11+
*/
12+
public class GenericList
13+
{
14+
// Default capacity
15+
private static final int DEFAULT_CAP = 10;
16+
17+
// iValues store the elements of the list and may have extra capacity
18+
private Object[] iValues;
19+
private int iSize;
20+
21+
/**
22+
* Creates an empty list.
23+
*/
24+
public GenericList()
25+
{
26+
//redirect to single int constructor
27+
this(DEFAULT_CAP);
28+
}
29+
30+
/**
31+
* Creates an empty list. Specify initial capacity.
32+
* @param initialCap > 0
33+
*/
34+
public GenericList(int initialCap)
35+
{
36+
if (initialCap <= 0)
37+
{
38+
throw new IllegalArgumentException("Must be a positive integer");
39+
}
40+
iValues = new Object[initialCap];
41+
iSize = 0;
42+
}
43+
44+
/**
45+
* Get list size.
46+
* @return size of list.
47+
*/
48+
public int size()
49+
{
50+
return iSize;
51+
}
52+
53+
/**
54+
* Get list element.
55+
* @param pos of the element in the list.
56+
* @return the list element.
57+
*/
58+
public Object get(int pos)
59+
{
60+
return iValues[pos];
61+
}
62+
63+
/**
64+
* Add element to the end of the list.
65+
* Size of the list goes up by 1.
66+
* @param element value to add.
67+
*/
68+
public void add(Object element)
69+
{
70+
insert(iSize, element);
71+
}
72+
73+
/**
74+
* Insert element at position.
75+
* @param pos of the element.
76+
* @param element to add.
77+
*/
78+
public void insert(int pos, Object element)
79+
{
80+
ensureCapcity();
81+
for(int i = iSize; i > pos; i--)
82+
{
83+
iValues[i] = iValues[i - 1];
84+
}
85+
iValues[pos] = element;
86+
iSize++;
87+
}
88+
89+
/**
90+
* Remove element at position.
91+
* @param pos of the element to remove.
92+
* @return removed element.
93+
*/
94+
public Object remove(int pos)
95+
{
96+
Object removedElement = iValues[pos];
97+
for(int i = pos; i < iSize - 1; i++)
98+
{
99+
iValues[i] = iValues[i + 1];
100+
}
101+
iValues[iSize - 1] = null;
102+
iSize--;
103+
return removedElement;
104+
}
105+
106+
/**
107+
* Return a String representation of list.
108+
* Size and elements included.
109+
* @return string representation of element.
110+
*/
111+
public String toString()
112+
{
113+
String result = "size: " + iSize + ", elements: [";
114+
for(int i = 0; i < iSize - 1; i++)
115+
{
116+
result += iValues[i].toString() + ", ";
117+
}
118+
if(iSize > 0 )
119+
{
120+
result += iValues[iSize - 1];
121+
}
122+
result += "]";
123+
return result;
124+
}
125+
126+
/**
127+
* Return a String representation of list.
128+
* Size and elements included.
129+
* @return string representation of element.
130+
*/
131+
public String toStringUsingStringBuffer()
132+
{
133+
StringBuffer result = new StringBuffer();
134+
result.append( "size: " );
135+
result.append( iSize );
136+
result.append(", elements: [");
137+
for(int i = 0; i < iSize - 1; i++)
138+
{
139+
result.append(iValues[i]);
140+
result.append(", ");
141+
}
142+
if( iSize > 0 )
143+
{
144+
result.append(iValues[iSize - 1]);
145+
}
146+
result.append("]");
147+
return result.toString();
148+
}
149+
150+
/**
151+
* Check if this list is equal to another.
152+
* @param other The object to comapre to.
153+
* @return true if other is a non null, IntList object
154+
* that is the same size as this IntList and has the
155+
* same elements in the same order, false otherwise.
156+
*/
157+
public boolean equals(Object other)
158+
{
159+
boolean result;
160+
if(other == null)
161+
{
162+
// we know this is not null so can't be equal
163+
result = false;
164+
}
165+
else if(this == other)
166+
{
167+
// quick check if this and other refer to same IntList object
168+
result = true;
169+
}
170+
else if(this.getClass() != other.getClass())
171+
{
172+
// other is not an IntList they can't be equal
173+
result = false;
174+
}
175+
else
176+
{
177+
// other is not null and refers to an IntList
178+
GenericList otherList = (GenericList)other;
179+
result = this.size() == otherList.size();
180+
int i = 0;
181+
while(i < iSize && result)
182+
{
183+
result = this.iValues[i].equals( otherList.iValues[i] );
184+
i++;
185+
}
186+
}
187+
return result;
188+
}
189+
190+
/**
191+
* Resize internal storage container by a factor of 2, if needed.
192+
*/
193+
private void ensureCapcity()
194+
{
195+
if(iSize == iValues.length)
196+
{
197+
Object[] temp = new Object[iValues.length * 2];
198+
System.arraycopy(iValues, 0, temp, 0, iValues.length);
199+
iValues = temp;
200+
}
201+
}
202+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.testspace.java.math;
2+
3+
/**
4+
* A class demonstrating simple mathematical operations.
5+
*
6+
* @author
7+
*
8+
*/
9+
public class MathOps
10+
{
11+
/**
12+
* Multiply two integers.
13+
* @param a first integer.
14+
* @param b second integer.
15+
* @return multiplied result integer.
16+
*/
17+
public static int mult(int a, int b)
18+
{
19+
return a * b;
20+
}
21+
/**
22+
* Add two integers.
23+
* @param a first integer.
24+
* @param b second integer.
25+
* @return result integer.
26+
*/
27+
public static int add(int a, int b)
28+
{
29+
return a + b;
30+
}
31+
/**
32+
* Subtract two integers.
33+
* @param a first integer.
34+
* @param b second integer.
35+
* @return result integer.
36+
*/
37+
public static int sub(int a, int b)
38+
{
39+
return a - b;
40+
}
41+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.testspace.java.string;
2+
3+
/**
4+
* A class demonstrating simple string operations.
5+
*
6+
* @author
7+
*
8+
*/
9+
public class StringOps
10+
{
11+
/**
12+
* Concatenate two strings.
13+
* @param a first string.
14+
* @param b second string.
15+
* @return concatenated string result.
16+
*/
17+
public static String concat(String a, String b)
18+
{
19+
a += b;
20+
return a;
21+
}
22+
23+
/**
24+
* Rerevse string.
25+
* @param s string to reverse.
26+
* @return reversed string result.
27+
*/
28+
public static String reverse(String s)
29+
{
30+
if (s.length() == 0)
31+
{
32+
return s;
33+
}
34+
35+
return reverse(s.substring(1)) + s.charAt(0);
36+
}
37+
}

0 commit comments

Comments
 (0)