Re: JUnit Test on JET Transform [message #39196] |
Fri, 11 January 2008 00:21 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Roshan,
Please use the M2T newsgroup for JET2 questions. I've added it to the
"to" list of the reply so there's no need to repost.
Roshan Soni wrote:
> Hi,
>
> I want to run a JUnit test on a JET2 template by running the
> transform, but whenever I try to run the transform inside of my test i.e.
> -JET2Platform.runTransformOnObject(...)
> -Compare results with expected output
> -assertTrue
>
> The problem is that the transformation is not being run. I tried to
> run it within a Job, but I still had no luck. Any ideas would be
> greatly appreciated:
>
> Job job = new Job("SD .NET Generation") {
> protected IStatus run(final IProgressMonitor monitor) {
> Map variablesMap = initializeInputs();
> JET2Platform.runTransformOnObject("project.transform", null,
> variablesMap, monitor);
>
> return Status.OK_STATUS;
> }
> };
>
|
|
|
|
|
|
|
Re: JUnit Test on JET Transform [message #41011 is a reply to message #40761] |
Thu, 24 January 2008 16:30 |
Paul Elder Messages: 849 Registered: July 2009 |
Senior Member |
|
|
Roshan:
I'm not an XMLUnit expert, but here's a suggestion on JUnit testing JET
transformation results...
1) Run the JET transformation using a TestSetup extension. See:
http://junit.sourceforge.net/javadoc/junit/extensions/TestSe tup.html
JET uses this technique in some if its JUnits:
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.m2t/org .eclipse.jet/tests/org.eclipse.jet.tests/src/org/eclipse/jet /tests/parser/resources/ResourceTemplateInputTest.java?revis ion=1.1&root=Modeling_Project&view=markup
2) With a TestSetup, individual tests in the JUnit class can than verify
individual file contents. If you have XML content to verify, the XMLUnit
would be a handy tool.
3) For Unit testing your XPath expressions, one possibility is to create a
template (and a ws:file action) that writes calculated values, and then
write a JUnit test to verify these values. If you don't want this template
run in normal circumstances, you could run it only if a particular XPath
variable is defined, and define that variable when you run the JUnit test.
Paul
"Roshan Soni" <roshan.soni1@gmail.com> wrote in message
news:288c21f6c2cc29d097162f4a2fafe771$1@www.eclipse.org...
> You're right it was a problem with my launch configuration and when I
> properly setup my launch to run the correct plugin. I was orignally
> running the same transform as my project and so my unit tests were not
> running, but changing it to run the org.eclipse.sdk.ide product runs my
> transformation and test.
>
> Now I have a different question. On the basis of unit testing I want to
> test my xpath. what would you say is a good test for the xpath in the
> template snippet below? I was want to use XMLUnit to test because all of
> my output is xml.
>
> <c:when test="string($someControl/@attribute1) != 'true'">
> <c:setVariable select="$composite_widget/@attribute1" var="myParent" />
> </c:when>
>
> Thanks,
> Roshan
>
|
|
|
Powered by
FUDForum. Page generated in 0.04668 seconds