Why does Beanshell choke on the '@' characters in source files?
-
22-04-2021 - |
سؤال
When interpreting a .java source file, in this case a JUnit test suite with the following declaration in it:
@RunWith(Suite.class)
@SuiteClasses({ MiamiAForm.class })
Why does Beanshell (version 1.3 and also 2.1b5) choke on those characters?
Evaluation Error: Sourced file: com\co\tests\TestSuite.java
Token Parsing Error: Lexical error at line 16, column 10.
Encountered: "B" (66), after : "@": <at unknown location>
المحلول
Because beanshell does not parse the syntax for some java 1.5 features. See Issue 24: Support of java 1.5 lang features (generics, enum, annotations), still open. Generics are now (partially) supported, but enums and annotations are not.
So it seems like it's not possible to run JUnit 4 tests under beanshell. Try Groovy, if you really don't want to compile them.
لا تنتمي إلى StackOverflow