I've been looking at some posts on StackOverflow to see how to set up testing with a MYSQL database.
I simply want to test some controller methods which will need a test database with some data in to return meaningful results. I want to use a real MYSQL database as that is what I will be using in production and I have read that there are quite a few differences between MYSQL and the InMemory database provided by Play.
In posts such as this one and this blog about testing Play! applications, the posts show examples that initialise a FakeApplication object with database parameters and then call Helper.start(fakeApp).
The docs for Helper.start(FakeApplication app) gives the following description:
Starts a new application.
OK great. But what processes are actually triggered off by calling start and what will that give me in a test?
Map<String, String> settings = new HashMap<String, String>();
settings.put("db.default.url", "jdbc:mysql://localhost/testdb");
settings.put("db.default.user", "root");
settings.put("db.default.password", "");
app = Helpers.fakeApplication(settings);
Helpers.start(app);
I was hoping that the above code would configure Ebean to use my test database, but when I try to execute a method such as Ebean.save() I get an error saying that no default database has been registered with Ebean. In order to register I will need to populate a ServerConfig object and create an EbeanServer from the EbeanServerFactory. In that case was there any point in passing the settings map to the FakeApplication object? And again, just what does starting a FakeApplication actually do? How can it be used?
Thanks in advance.