From 1e4d0abc66840c6827c0a8248c99a34fc253e9fd Mon Sep 17 00:00:00 2001 From: Sidharth Guglani Date: Mon, 29 Oct 2018 04:28:50 -0700 Subject: [PATCH] using TestParametrization.NodeFactory in gentest-java.js to generate java tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: @public Our tests were manually parametrized, without adding the necessary code to the test case generation script. This commit makes the necessary changes so that test generation won’t overwrite the parametrization. Reviewed By: davidaurelio Differential Revision: D10853163 fbshipit-source-id: b5e41755df16a6a296cf2061fbb89c3f27f8574d --- gentest/gentest-java.js | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/gentest/gentest-java.js b/gentest/gentest-java.js index 6b6d34c4..033417e2 100644 --- a/gentest/gentest-java.js +++ b/gentest/gentest-java.js @@ -42,13 +42,29 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { this.push([ 'package com.facebook.yoga;', '', - 'import org.junit.Test;', - '', 'import static org.junit.Assert.assertEquals;', '', + 'import org.junit.Test;', + 'import org.junit.runner.RunWith;', + 'import org.junit.runners.Parameterized;', + '', + '@RunWith(Parameterized.class)', 'public class YogaTest {', ]); this.pushIndent(); + this.push([ + '@Parameterized.Parameters(name = "{0}")', + 'public static Iterable nodeFactories() {', + ]); + this.pushIndent(); + this.push('return TestParametrization.nodeFactories();'); + this.popIndent(); + this.push('}'); + this.push([ + '', + '@Parameterized.Parameter public TestParametrization.NodeFactory mNodeFactory;', + '', + ]); }}, emitTestPrologue:{value:function(name, experiments) { @@ -64,7 +80,7 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { }}, emitTestTreePrologue:{value:function(nodeName) { - this.push('final YogaNode ' + nodeName + ' = new YogaNode(config);'); + this.push('final YogaNode ' + nodeName + ' = createNode(config);'); }}, emitTestEpilogue:{value:function(experiments) { @@ -76,6 +92,11 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, { }}, emitEpilogue:{value:function(lines) { + this.push('private YogaNode createNode(YogaConfig config) {'); + this.pushIndent(); + this.push('return mNodeFactory.create(config);'); + this.popIndent(); + this.push('}'); this.popIndent(); this.push([ '}',