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

Can't use it from unit tests in Android #48

Open
ivnsch opened this issue Jun 16, 2017 · 8 comments
Open

Can't use it from unit tests in Android #48

ivnsch opened this issue Jun 16, 2017 · 8 comments

Comments

@ivnsch
Copy link

ivnsch commented Jun 16, 2017

When executed from a unit test in Android, Fakeit.init() throws an exception:

org.yaml.snakeyaml.error.YAMLException: java.io.IOException: Stream closed

at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:200)
at org.yaml.snakeyaml.reader.StreamReader.(StreamReader.java:60)
at org.yaml.snakeyaml.Yaml.load(Yaml.java:381)
at com.mooveit.library.Fakeit.getValues(Fakeit.kt:79)
at com.mooveit.library.Fakeit.(Fakeit.kt:69)
at com.mooveit.library.Fakeit.(Fakeit.kt:49)
at com.mooveit.library.Fakeit$Companion.fakeitInit(Fakeit.kt:233)
at com.mooveit.library.Fakeit$Companion.initWithLocale(Fakeit.kt:253)
at com.mooveit.library.Fakeit$Companion.initWithLocale(Fakeit.kt:259)
at com.mooveit.library.Fakeit$Companion.init(Fakeit.kt:247)
at xx.xxxxxx.xxxxx.viewmodels.LibraryViewModel.(LibraryViewModel.kt:104)
at xx.xxxxxx.xxxxx.SMMLibraryNavTests.setup(SMMLibraryNavTests.kt:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

@jotaemepereira
Copy link
Contributor

jotaemepereira commented Jun 16, 2017

Thanks for the report @i-schuetz. Can you test it on v0.5?

https://github.com/moove-it/fakeit/releases/tag/v0.5

@jmfayard
Copy link

@jotaemepereira I have the same bug on v0.7
on v0.5 I get an error java.io.FileNotFoundException: library/src/main/assets/locales/en.yml (No such file or directory)

@jmfayard
Copy link

Tested it again, bug still present

@mrjano
Copy link

mrjano commented Nov 28, 2017

I was having this issue while running the project (not from unit tests), downgrading to 0.4 fixed it for me

@TheMaxCoder
Copy link

Same here, 0.5 isn't working and I'm getting the same exception as above. 0.4 works fine though

@Byronium
Copy link

Byronium commented Feb 24, 2018

v0.4, v0.6, and v0.7 give me org.yaml.snakeyaml.error.YAMLException: java.io.IOException: Stream closed when I try to do Fakeit.init().

v0.5 gives me java.io.FileNotFoundException: library/src/main/assets/locales/en.yml (No such file or directory), just like @jmfayard mentioned.

@dsebastien
Copy link

I get the same error as @Byronium with v0.7 unless I copy the correct yml file to my app's debug/res/raw folder.

@tamhuynhit
Copy link

Same for me in Unit testing

org.yaml.snakeyaml.error.YAMLException: java.io.IOException: Stream closed in v0.7

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

8 participants