Closed wishingmaid closed 6 years ago
Have you tried deleting your own personal Addressbook.xml file and running again on your local machine?
I'm assuming that the initiation of a new addressbook is the one throwing the error.
Yes , my own personal Addressbook.xml file is already deleted before I ran the tests. There no files under 'data' when these tests are performed.
The error comes from around
dataToWrite = new XmlSerializableAddressBook(
builder.withPerson(new PersonBuilder().build()).withTag("Friends").build());
When you ran your gradlew headless tests, what unix command did you use? As in, what options did you parse into gradlew?
If you did not use the following, try using
./gradlew clean checkstyleMain checkstyleTest headless allTests coverage coveralls asciidoctor
I wrote : gradlew headless allTests. I tried the command you suggested but it still gives me the same exact errors.
Could you post the log for your error? assuming there's more information there for me to work with as well.
These are the images of the full log arranged in order.
Ok, i'll try and run your fork on my end and see what's going on
The files are here : https://github.com/CS2103AUG2017-T10-B2/main/tree/v1.3.2(ZX)-noChangesToTest
This is the respective PR that failed on TravisCI which I believe for the same reason that failed in headless mode. https://github.com/CS2103AUG2017-T10-B2/main/pull/44
Ok, i'll try and run your fork on my end and see what's going on
Kudos to @wishingmaid helping out 👍
@wishingmaid what happens when you run tests in headfull (i.e. not headless) mode using gradlew? Did you add any extra library for this feature?
Kudos to @wishingmaid helping out 👍
I meant: Kudos to @hansiang93 helping out 👍
By headfull, do you mean "right click all test folder" and run? If yes, I successfully passed all 260 test cases as shown on my previous post. I did import ImageView library class as I am doing an addphoto enhancement.
@wishingmaid the libraries mentioned seem to be third party libraries, such as google apis, or linkedin ones etc. I don't see these in your code atm.
I'd suggest trying this out. Merge your current working master tagged v1.3.2 onto your branch. Test it out again from there.
you might even find out where the problems are.
At the moment, i'm assuming it's a gradle environment problem and nothing else. It seems to be unable to load a class, or a library as suggested by @damithc. I don't see any differences between your gradle.config and mine, nor did i see any major additions in terms of libraries externally added onto a folder that gradle did not take into account.
I did however, notice you deleted a "Photo.java" and moved it under "Person". Could that be it?
I cant merge into my working branch because it fails TravisCI tests(it gives the same results as running in headless mode).
could the issues be due to "/images/noPhoto.png"?
After moving photo.java into Person , I made changes to the imports classpath as needed, so I assume it shouldnt be a problem. "/images/noPhoto.png" is under the designated resources file which I referenced correctly, seeing that the image shows up correctly.
Yeah that's true, i don't see any issues there.
Try re basing your changes onto the current branch, see if that helps? It does not seem to be a code problem, but an environment problem in terms of the gradle configs, either an unreferenced Jar file, library or testing file environment.
I have actually tried it. I cloned the previous v1.3.2 without my code and manually added all my code. This became my latest PR which was using v1.3.2 as the base, which failed.
To run tests using gradle in headfull mode, use this command:
./gradlew clean allTests
To ensure your branch is up to date with target branch,
git checkout targetbranch
git pull origin targetbranch
git checkout yourbranch
git merge targetbranch
Surprisingly , I got more errors from gradlew clean allTests
, 8 more to be precise.
Surprisingly , I got more errors from gradlew clean allTests , 8 more to be precise.
That means it's not about headless or headfull. It's something to do with gradle.
To confirm the error is caused by your branch, try running the same command gradlew clean allTests
for your target branch (the one you are trying to merge to).
Are you using Windows? In that case note that Travis uses Unix and OS-sensitive code (e.g. hard-coded file paths) can cause tests to pass locally but fail on Travis.
Did you try removing the opening "/images/noPhoto.png"
? Not sure if Unix interprets the /
as a path relative to root directory.
I tried running gradle clean allTests
on my target branch and it gave 8 errors.
Yes I am using Windows.
I'll try removing the /
to see if it works.
@Zhiyuan-Amos who do you run tests in gradle in verbose mode so that we can see exactly where the tests are failing?
I tried removing /
in my /images/noPhoto.png
. Java cant recognize the resources folder it is in and throws a nullpointerException during runtime. gradlew clean allTests
still fails.
who do you
Sorry prof what do you mean by this phrase? ><
@Zhiyuan-Amos who
-> how
? sorry :-p
Anyway, see if you can figure out what's wrong with @wishingmaid's code.
With regards to hard-coded filepath, does that mean that travisCI might not be able to recognize that /images/noPhoto.png which is stored in the designated resource folder and therefore fails ?
I faced a similar problem. But not such a huge one. My Travis tests kept failing cause of file path.
How about trying images/noPhoto.png
instead of /images/noPhoto.png
Also make sure that such an image and path is already being created. For that try running using your jar file and checking the contents of the folder
Edit: Just read the thread properly. Sorry for giving redundant advice. Since it looked very much like the problem I had I jumped to conclusions.
Anyways, since removing the / gives a NullPointerException, then go ahead and create a folder with name images and put an image into it. Create this folder on the same level as jar. E.g if your Jar file is in C:\User\Desktop\iContacts\addressbook.jar then even the images
folder should be placed there in C:\User\Desktop\iContacts\
Hope the problem can be resolved by this
@tshradheya Sorry , what do you mean by the same level as jar?
@tshradheya my noPhoto.png is stored under the designated resources folder under src/main/resources/images/noPhoto.png
If they are stored in the designated resource folder, then it should be correct. Sorry, my bad. Could I have the link to your PR? The links above seem to be broken
Could I have the link to your PR? The links above seem to be broken
Correct link https://github.com/CS2103AUG2017-T10-B2/main/pull/44
The link for the branch is https://github.com/CS2103AUG2017-T10-B2/main/tree/v1.3.2(ZX)-noChangesToTest
how do you run tests in gradle in verbose mode so that we can see exactly where the tests are failing?
Have to append -s or -S. Perhaps @wishingmaid can try running the tests with either of the options and post the log again :)
After running in with --stacktrace
appended, I get the same errors with some additional lines at the end.
Posted in order :
hm ok. It seems like your tests begin to fail from the first commit "added-addphoto functionality(zx)". It fails on gradle non-headless, gradle headless & junit (i.e. running the tests on IntelliJ).
The error message points towards TypicalPersons:27. I'm guessing there's something wrong with your withPhoto
method, causing this error as seen in the image java.lang.RuntimeException: Internal graphics not initialized yet
.
Side note: Next time, do test out which commit is causing the code to break. That way, it's easier for others to follow up :P
After some digging on the web , I realised that all JavaFx objects can only be initialized if the main class extends Application(perhaps explaining why I encounter no errors when running the program manually). Else it will throw errors like Internal graphics not initialized yet , which I assumed that the tests class does not extend application(correct me if I am wrong). Now my solution is to not call Image class in PersonBuilder which I assume will throw the error during the tests. Please advice if that is a plausible.
which I assumed that the tests class does not extend application(correct me if I am wrong).
TestApp extends MainApp
, and MainApp extends Application
. However, you are right in that not all tests use TestApp
, for example, one of the tests that are failing AddCommandIntegrationTest
does not use TestApp
.
Now my solution is to not call Image class in PersonBuilder
Seems like the quick solution is to not call Image
class at all for all tests that do not use TestApp
.
Ok, I have resolved the issue by removing all calling of Image class in TestApp.
Thank you to @hansiang93 @damithc @Zhiyuan-Amos @tshradheya for helping out.
My code is failing in headless mode on Intellij despite passing all the tests in the normal
right click and run allTests
method. The headless mode prints RuntimeException or NoClassDefFoundError for certain tests and in reaction to that I tried to run alltests in debug mode. Everything runs smoothly in debug mode without any RuntimeException or NoClassDefFoundError.Any help will be much appreciated.