Can I mock a database connection ?

56 views
Skip to first unread message

Eduardo

unread,
Sep 29, 2021, 9:35:56 AM9/29/21
to iDempiere
Hello,

I'm trying to mock some POs objects without using the database. I want to use simple JUnit tests like that:

public class MyTest {

    @Test
    public void testMUser() {
        Properties ctx; // init ctx...;
        MUser user = Muser.get(ctx, 100);
        assertEquals(user.getName(), "Super User");
    }
}

I don't want to use the AdempiereTestCase and runs as JUnit Plug-in Test with all the required bundles.

Can I mock the database to instance my POs from a txt file for example, json or other resource ? I tried the mockito library but it didn't work in more complex tests.

Regards,
Eduardo


Reply all
Reply to author
Forward
0 new messages