[Acceleo] Advices for unit testing ? [message #495299] |
Wed, 04 November 2009 09:23  |
Eclipse User |
|
|
|
In the scope of my code generation project, I would like to perform automated unitary tests of the transformation results.
Does anyone has already experienced unit testing with M2T ?
What is the best way to perform that ?
Thank you for your answers
Sebastien
|
|
|
|
|
|
Re: [Acceleo] Advices for unit testing ? [message #670923 is a reply to message #495602] |
Mon, 16 May 2011 04:22   |
Eclipse User |
|
|
|
Hello,
Is there any news about the unit test of templates?
I have developed a unit test to check one of my generators, but when I break my generator the unit test does not failed. No exception is thrown but I can find message in the log.
I use the following line to launch the generator :
new HtmlReport(benchmark, targetDirectory, new ArrayList<Object>()).doGenerate(null);
How should I call my generator to be able to get an exception when my generator fails? To be able to get those exceptions would be really use full to develop low cost unit tests.
I get such kind of Exception :
!ENTRY org.eclipse.ocl 4 10 2011-05-13 19:27:57.956
!MESSAGE Evaluation failed with an exception: index: 0, size: 10
!STACK 0
java.lang.IndexOutOfBoundsException: index: 0, size: 10
at org.eclipse.ocl.util.CollectionUtil.at(CollectionUtil.java:8 86)
at org.eclipse.ocl.EvaluationVisitorImpl.visitOperationCallExp( EvaluationVisitorImpl.java:1213)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvalua tionVisitor.visitOperationCallExp(AcceleoEvaluationVisitor.j ava:1064)
at org.eclipse.ocl.ecore.impl.OperationCallExpImpl.accept(Opera tionCallExpImpl.java:390)
at org.eclipse.ocl.EvaluationVisitorImpl.visitPropertyCallExp(E valuationVisitorImpl.java:2061)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvalua tionVisitor.visitPropertyCallExp(AcceleoEvaluationVisitor.ja va:1075)
at org.eclipse.ocl.ecore.impl.PropertyCallExpImpl.accept(Proper tyCallExpImpl.java:238)
at org.eclipse.ocl.AbstractEvaluationVisitor.visitExpression(Ab stractEvaluationVisitor.java:248)
at org.eclipse.ocl.EvaluationVisitorDecorator.visitExpression(E valuationVisitorDecorator.java:156)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvalua tionVisitor.switchExpression(AcceleoEvaluationVisitor.java:1 650)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvalua tionVisitor.visitExpression(AcceleoEvaluationVisitor.java:96 3)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvalua tionVisitor.visitAcceleoForBlock(AcceleoEvaluationVisitor.ja va:402)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvalua tionVisitor.switchExpression(AcceleoEvaluationVisitor.java:1 613)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvalua tionVisitor.visitExpression(AcceleoEvaluationVisitor.java:96 3)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvalua tionVisitor.visitAcceleoFileBlock(AcceleoEvaluationVisitor.j ava:386)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvalua tionVisitor.switchExpression(AcceleoEvaluationVisitor.java:1 620)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvalua tionVisitor.visitExpression(AcceleoEvaluationVisitor.java:96 3)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvalua tionVisitor.visitAcceleoTemplate(AcceleoEvaluationVisitor.ja va:832)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvalua tionVisitor.switchExpression(AcceleoEvaluationVisitor.java:1 600)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvalua tionVisitor.visitExpression(AcceleoEvaluationVisitor.java:96 3)
at org.eclipse.ocl.internal.evaluation.QueryImpl.evaluate(Query Impl.java:152)
at org.eclipse.ocl.ecore.QueryImpl.evaluate(QueryImpl.java:62)
at org.eclipse.acceleo.engine.generation.AcceleoEngine.doEvalua te(AcceleoEngine.java:265)
at org.eclipse.acceleo.engine.generation.AcceleoEngine.evaluate (AcceleoEngine.java:130)
at org.eclipse.acceleo.engine.service.AcceleoService.doGenerate Template(AcceleoService.java:765)
at org.eclipse.acceleo.engine.service.AcceleoService.doGenerate (AcceleoService.java:478)
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator. generate(AbstractAcceleoGenerator.java:175)
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator. doGenerate(AbstractAcceleoGenerator.java:154)
at org.eclipse.modisco.java.discoverer.benchmark.template.html. HtmlReport.doGenerate(HtmlReport.java:195)
at org.eclipse.modisco.java.discoverer.benchmark.Report.generat eHTML(Report.java:324)
at org.eclipse.modisco.java.discoverer.benchmark.Report.generat e(Report.java:102)
at org.eclipse.modisco.java.discoverer.benchmark.RunBenchmark.c reateReport(RunBenchmark.java:44)
at org.eclipse.modisco.java.discoverer.benchmark.tests.JavaDisc overerBenchmarkTest.test001(JavaDiscovererBenchmarkTest.java :50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall( FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(Refl ectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(Fr ameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate( InvokeMethod.java:20)
at org.junit.internal.runners.statements.FailOnTimeout$1.run(Fa ilOnTimeout.java:28)
!ENTRY org.eclipse.acceleo.engine 2 2 2011-05-13 19:27:57.956
!MESSAGE Invalid loop iteration at line 49 in Module htmlReport for block for (b.projects->at(0).discoveries). Last recorded value of self was org.eclipse.modisco.infra.discovery.benchmark.impl.MultiProj ectBenchmarkImpl @8966e9 (jvmMaxHeapInMiB: 0, processorName: null, processorDescription: null, processorCount: 0, processorCacheSize: null, systemMemory: null, osName: null, osVersion: null, osArchitecture: null).
!STACK 0
org.eclipse.acceleo.engine.AcceleoEvaluationException: Invalid loop iteration at line 49 in Module htmlReport for block for (b.projects->at(0).discoveries). Last recorded value of self was org.eclipse.modisco.infra.discovery.benchmark.impl.MultiProj ectBenchmarkImpl @8966e9 (jvmMaxHeapInMiB: 0, processorName: null, processorDescription: null, processorCount: 0, processorCacheSize: null, systemMemory: null, osName: null, osVersion: null, osArchitecture: null).
at htmlReport.htmlReport(MultiProjectBenchmark)(htmlReport.mtl: 49)
at htmlReport.htmlReport(MultiProjectBenchmark)(htmlReport.mtl: 17)
at htmlReport.htmlReport(MultiProjectBenchmark)(htmlReport.mtl: 14)
|
|
|
|
|
Re: [Acceleo] Advices for unit testing ? [message #671582 is a reply to message #671324] |
Wed, 18 May 2011 07:54  |
Eclipse User |
|
|
|
Hi,
"but when I break my generator the unit test does not failed"
If you want to detect errors during the parsing of your generator, you may want to look at the test project org.eclipse.acceleo.parser.tests.
This utility class used for our test may help you. You can see how we are using it here.
We are checking for informations, warnings and errors during each steps of the compilation, like this:
checkCSTParsing(moduleFile, 0, 0, 0);
checkCST2ASTConvertion(1, 0, 0);
checkASTResolution(1, 0, 0);
checkASTDocumentationResolution(1, 0, 0);
You woudln't have to launch the generation for that.
Stephane Begaudeau, Obeo
--
Twitter: @sbegaudeau
Acceleo wiki: http://wiki.eclipse.org/Acceleo
Blogs: http://stephanebegaudeau.tumblr.com & http://sbegaudeau.tumblr.com
|
|
|
Powered by
FUDForum. Page generated in 0.05083 seconds