Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a sample test case #9

Open
Brazo opened this issue Feb 4, 2014 · 6 comments
Open

Add a sample test case #9

Brazo opened this issue Feb 4, 2014 · 6 comments

Comments

@Brazo
Copy link

Brazo commented Feb 4, 2014

Hello guys,

thanks a lot for providing this neo4j plugin. It saves a lot of time configuring play correctly.

One thing I am missing is a sample test case. Could you provide a sample test case for the Galaxy example? Something simple that checks Neo4JServiceProvider.get() actually returns a non-null Neo4jServiceProvider, e.g. a non-null galaxyService?

This worked for me using your plugin:
@test
public void serviceIsCorrectlyRegistered() {
running(fakeApplication(), new Runnable() {
public void run() {
Neo4JServiceProvider nsp = Neo4JServiceProvider.get();
assertNotNull("Neo4jService is not correctly wired by Spring", nsp);
GalaxyService ms = nsp.galaxyService;
assertNotNull("GalaxyService is not correctly wired by Spring", ms);
} });
}

Thanks
Patrick

@tuxBurner
Copy link
Owner

Hi @Brazo,

thanks for the feedback. I will write some test cases

@tuxBurner tuxBurner reopened this Feb 5, 2014
@tuxBurner
Copy link
Owner

Ups wrong button :)
Coffee is still not working.

@pkishore
Copy link

pkishore commented May 9, 2014

Thanks for providing this plugin. When using the same test provided by @Brazo,i am getting a nullexception below. Anyideas on what could be wrong?

java.lang.NullPointerException
at neo4jplugin.Neo4JPlugin.get(Neo4JPlugin.java:105)

Code:
running(fakeApplication(), new Runnable() {
public void run() {
Neo4JServiceProvider nsp = Neo4JServiceProvider.get();
assertNotNull("Neo4jService is not correctly wired by Spring", nsp);
}
});

Update:
Hi Sepp,
The tests provided by @Brazo are working when run from prompt with "play test" ,there is no issue now . Earlier i was trying to run from eclipse ,where it was failing with the NullPointer exception.

Thanks,
Kishore

@tuxBurner
Copy link
Owner

Ups okay i will try to check this at the weekend

@haimingzhao
Copy link

I found a simple solution to enable us to write unit test. The test will take long tho because it require starting the application. It is not a perfect solution because the test will break if simply the application break(because it need to start the app to enable us to use the plugin), which make the test not isolated.

So basically the test class need to extends play.test.WithApplication
And we add Service as a field, then add a setUp method to start the application, get the service before we start the testing. After that we will be able to use the Service object.

@Before
public void setUp() throws Exception {
    this.startPlay();
    this.citationService = Neo4JServiceProvider.get().citationService;
}

@tuxBurner
Copy link
Owner

Woaaah cool one @mirahmz thx a lot :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants