exporting tests to junit format to be used by jenkins
This commit is contained in:
parent
bf80fca2c0
commit
d60ed6c15a
|
@ -75,4 +75,5 @@ dependencies {
|
||||||
compile 'com.android.support:appcompat-v7:23.0.1'
|
compile 'com.android.support:appcompat-v7:23.0.1'
|
||||||
compile 'com.facebook.react:react-native:0.18.0-patched'
|
compile 'com.facebook.react:react-native:0.18.0-patched'
|
||||||
compile 'io.realm.react:realm-react-native:0.0.1-SNAPSHOT'
|
compile 'io.realm.react:realm-react-native:0.0.1-SNAPSHOT'
|
||||||
|
compile project(':react-native-fs')
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import com.facebook.react.bridge.ReactApplicationContext;
|
||||||
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
|
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
|
||||||
import com.facebook.react.shell.MainReactPackage;
|
import com.facebook.react.shell.MainReactPackage;
|
||||||
import com.facebook.react.uimanager.ViewManager;
|
import com.facebook.react.uimanager.ViewManager;
|
||||||
|
import com.rnfs.RNFSPackage;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -36,6 +37,7 @@ public class MainActivity extends Activity implements DefaultHardwareBackBtnHand
|
||||||
.setBundleAssetName("index.android.bundle")
|
.setBundleAssetName("index.android.bundle")
|
||||||
.setJSMainModuleName("index.android")
|
.setJSMainModuleName("index.android")
|
||||||
.addPackage(new MainReactPackage())
|
.addPackage(new MainReactPackage())
|
||||||
|
.addPackage(new RNFSPackage())
|
||||||
.addPackage(new AnExampleReactPackage())
|
.addPackage(new AnExampleReactPackage())
|
||||||
.setUseDeveloperSupport(BuildConfig.DEBUG)
|
.setUseDeveloperSupport(BuildConfig.DEBUG)
|
||||||
.setInitialLifecycleState(LifecycleState.RESUMED)
|
.setInitialLifecycleState(LifecycleState.RESUMED)
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
|
@ -1,3 +1,5 @@
|
||||||
rootProject.name = 'Demo'
|
rootProject.name = 'Demo'
|
||||||
|
|
||||||
include ':app'
|
include ':app'
|
||||||
|
include ':react-native-fs'
|
||||||
|
project(':react-native-fs').projectDir = new File(settingsDir, '../node_modules/react-native-fs/android')
|
||||||
|
|
|
@ -8,6 +8,7 @@ var React = require('react-native');
|
||||||
var {
|
var {
|
||||||
AppRegistry,
|
AppRegistry,
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
|
Image,
|
||||||
Text,
|
Text,
|
||||||
View,
|
View,
|
||||||
TouchableNativeFeedback,
|
TouchableNativeFeedback,
|
||||||
|
@ -16,18 +17,33 @@ var {
|
||||||
var RealmReactAndroid = require('NativeModules').RealmReactAndroid;
|
var RealmReactAndroid = require('NativeModules').RealmReactAndroid;
|
||||||
var Realm = require('realm');
|
var Realm = require('realm');
|
||||||
var RealmTests = require('realm-tests');
|
var RealmTests = require('realm-tests');
|
||||||
|
var builder = require('xmlbuilder');
|
||||||
|
var RNFS = require('react-native-fs');
|
||||||
|
|
||||||
function runTests() {
|
function runTests() {
|
||||||
|
var rootXml = builder.create('testsuites');
|
||||||
|
|
||||||
|
|
||||||
let testNames = RealmTests.getTestNames();
|
let testNames = RealmTests.getTestNames();
|
||||||
|
|
||||||
|
|
||||||
for (let suiteName in testNames) {
|
for (let suiteName in testNames) {
|
||||||
|
var itemTestsuite = rootXml.ele('testsuite');
|
||||||
|
let nbrTests = 0;
|
||||||
|
let nbrFailures = 0;
|
||||||
|
|
||||||
let testSuite = RealmTests[suiteName];
|
let testSuite = RealmTests[suiteName];
|
||||||
|
|
||||||
console.log('Starting ' + suiteName);
|
console.log('Starting suite ' + suiteName);
|
||||||
|
|
||||||
var suiteTestNames = testNames[suiteName];
|
var suiteTestNames = testNames[suiteName];
|
||||||
for (var index in suiteTestNames) {
|
for (var index in suiteTestNames) {
|
||||||
|
nbrTests++;
|
||||||
var testName = suiteTestNames[index];
|
var testName = suiteTestNames[index];
|
||||||
|
|
||||||
|
var itemTest = itemTestsuite.ele('testcase');
|
||||||
|
itemTest.att('name', testName);
|
||||||
|
|
||||||
console.log('Starting ' + testName);
|
console.log('Starting ' + testName);
|
||||||
|
|
||||||
if (testSuite.beforeEach) {
|
if (testSuite.beforeEach) {
|
||||||
|
@ -41,6 +57,9 @@ function runTests() {
|
||||||
catch (e) {
|
catch (e) {
|
||||||
console.log('- ' + testName);
|
console.log('- ' + testName);
|
||||||
console.warn(e.message);
|
console.warn(e.message);
|
||||||
|
|
||||||
|
itemTest.ele('error', {'message': ''}, e.message);
|
||||||
|
nbrFailures++;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (testSuite.afterEach) {
|
if (testSuite.afterEach) {
|
||||||
|
@ -48,20 +67,46 @@ function runTests() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update Junit XML report
|
||||||
|
itemTestsuite.att('name', suiteName);
|
||||||
|
itemTestsuite.att('tests', nbrTests);
|
||||||
|
itemTestsuite.att('failures', nbrFailures);
|
||||||
|
itemTestsuite.att('timestamp', "2016-01-22T14:40:44.874443-05:00");//TODO use real timestamp
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// export unit tests results
|
||||||
|
var xmlString = rootXml.end({ pretty: true, indent: ' ', newline: '\n' });
|
||||||
|
var path = RNFS.DocumentDirectoryPath + '/tests.xml';
|
||||||
|
|
||||||
|
// write the unit tests reports
|
||||||
|
RNFS.writeFile(path, xmlString , 'utf8')
|
||||||
|
.then((success) => {
|
||||||
|
console.log('FILE WRITTEN!!');
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.log(err.message);
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var Demo = React.createClass({
|
var Demo = React.createClass({
|
||||||
render: function() {
|
render: function() {
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<Text style={styles.button} onPress={runTests}>
|
<Text style={styles.button} onPress={runTests}>
|
||||||
Tap to Run Tests
|
Running Tests...
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
|
||||||
|
<Image
|
||||||
|
style={styles.icon}
|
||||||
|
source={require('image!ic_launcher')}
|
||||||
|
onLoad={() => runTests()}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var styles = StyleSheet.create({
|
var styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"react-native": "^0.18.0-rc",
|
"react-native": "^0.18.0-rc",
|
||||||
|
"react-native-fs": "^1.1.0",
|
||||||
"realm": "file:../..",
|
"realm": "file:../..",
|
||||||
"realm-tests": "file:../lib"
|
"realm-tests": "file:../lib"
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,5 +3,4 @@ rm -rf node_modules/realm node_modules/realm-tests
|
||||||
npm install realm realm-tests
|
npm install realm realm-tests
|
||||||
cp ../../src/object-store/parser/queryTests.json node_modules/realm-tests/query-tests.json
|
cp ../../src/object-store/parser/queryTests.json node_modules/realm-tests/query-tests.json
|
||||||
adb forward tcp:8082 tcp:8082
|
adb forward tcp:8082 tcp:8082
|
||||||
adb reverse tcp:8081 tcp:8081
|
|
||||||
react-native run-android
|
react-native run-android
|
||||||
|
|
Loading…
Reference in New Issue