1

In the quest of getting JUnit tests to be part of how we use Ryhtm we came up with the code snippet below. All went well until we added

@Test

which obviously is a java annotation and uses the @ marker as a syntax element that is also being used by Rythm. How can the desired effect be achieved to get the @annotation? To simply escape the @@ does not work it gives a

Syntax error on token "@", delete this token

error. So How can a Java @ annotation be used ?

I have also filed this as a bug report at https://github.com/greenlaw110/Rythm/issues/285

@// This is a rythm template
@import static org.junit.Assert.*
@import org.junit.Test.*
@def static {
  class TestMe {
    String name;
    @Test
    public void testMe() {
      name="test";
      assertEquals("test",name);
    }
  }
}
@{
  TestMe testme=new TestMe();
  testme.name="testme";
}
The TestMe has the name @(testme.name)
4

2 回答 2

1

If you use a fully qualifying annotation it should work:

 @org.junit.Test
于 2015-10-10T13:19:15.827 回答
1

@import org.junit.Test.* in your template code should be @import org.junit.Test, note that .* needs to be take off

于 2015-10-11T03:21:12.773 回答