forked from cucumber/cucumber-jvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestHelper.java
40 lines (35 loc) · 1.27 KB
/
TestHelper.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package cucumber.runtime;
import cucumber.runtime.io.Resource;
import cucumber.runtime.model.CucumberFeature;
import org.junit.Ignore;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
@Ignore
public class TestHelper {
public static CucumberFeature feature(final String path, final String source) throws IOException {
ArrayList<CucumberFeature> cucumberFeatures = new ArrayList<CucumberFeature>();
FeatureBuilder featureBuilder = new FeatureBuilder(cucumberFeatures);
featureBuilder.parse(new Resource() {
@Override
public String getPath() {
return path;
}
@Override
public InputStream getInputStream() {
try {
return new ByteArrayInputStream(source.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
@Override
public String getClassName() {
throw new UnsupportedOperationException();
}
}, new ArrayList<Object>());
return cucumberFeatures.get(0);
}
}