mardi 1 mars 2016

Play 2.4.6, configuring build settings for bytecode enhancement in tests

I'm using Play framework 2.4.6 with Ebean and Java.

When I run my tests, I cannot set the value of any field. I think the bytecode enhancement (automatic getter/setter generation) doesn't work.

My test (keep calm, the framework is supposed to put the getter/setter for "name"):

    @Test
    public void createAndUpdate() {
        running(fakeApplication(), new Runnable() {
            public void run() {
                Usuario newUser = new Usuario("bob@gmail.com", "secret", "Spongebob Squarepants");
                newUser.save();

                Usuario alterUser = Usuario.find.where().eq("email", "bob@gmail.com").findUnique();
                alterUser.name = "another name";
                alterUser.update();

                Usuario bob = Usuario.find.where().eq("email", "bob@gmail.com").findUnique();

                assertNotNull(bob);
                assertEquals("another name", bob.name);
            }
        });
    }

I tried using save() instead of update() with no desired results.

The test fails; output:

[error] Test IntegrationTest.createAndUpdate failed: expected:<[another name]> but was:<[Spongebob Squarepants]>, took 0.228 sec

I've read that Play bytecode enhancement doesn't work for the code into the "test" directory. According to this post http://ift.tt/1Tl4bEl, I need to configure the buid.scala file like this http://ift.tt/1XYbwbX

The post is for the version 2.0.x so it uses the build.scala file, but for 2.4.x the build settings are into build.sbt and I haven't achieved to load it without errors.

The question is, How can I configure the build settings file to work as the above post states but using the new build.sbt style?

I also tried to use the old build.scala only, but it gives me errors in every line.

I'm aware that the easiest solution is to manually put the getters/setters, but I'd like to try using the Play style.

Any help would be appreciated.

Aucun commentaire:

Enregistrer un commentaire