[Solved] enum/.../.members access in Test context

Hi,

I try to write a BTestCase where I iterate over an enum's member like so

foreach member in enum/MyEnum/.members {

   // test something

}

However, I get the following exception:

java.lang.NullPointerException
 at jetbrains.mps.lang.smodel.generator.smodelAdapter.SEnumOperations.getEnum(SEnumOperations.java:19)

I tried to access other operations on my enum/MyEnum/, resulting in the same Exception. I also tried to access an enum in the context of a NodeTestCase, also witht he same exception.

Any advice?

Thanks!

 

 

 

 

 

 

3 comments
Comment actions Permalink

According to some feedback on the Slack channel, SModel components are not initialized in UnitTests which causes the exception.

0
Comment actions Permalink

Hi,

I am able to test the members of the enum with MPS 2017.1. Can you please pinpoint the problem exactly?

 

Thanks,

Narendran

0
Comment actions Permalink

Hi Narendran,

there seems to be a misunderstanding. What I was trying to do was to iterate over the members of a "language enum" (i.e. an Enum you define in the structure aspect) from within a BTestCase. I learned from a discussion in the MPS slack channel that the SModel components are not initialized for such Unit tests.

Like in your example, I can test the members of such an enum in a NodeTest as well. I was basically just not aware that the SModel components are uninitialized when a BTestCase is run. Why it didn't work initially in a NodeTest I could not reproduce.

Best,

Robert

0

Please sign in to leave a comment.