error: package org.robolectric does not exist

542 views
Skip to first unread message

tester test

unread,
Aug 11, 2015, 7:08:28 PM8/11/15
to Robolectric


Hi,


I’ve added a simple test using robolectric framework, however when I try running my test I’m getting the following failures…


Error:(4, 23) error: package org.robolectric does not exist

Error:(5, 24) error: package org.junit.runner does not exist

Error:(6, 17) error: package org.junit does not exist

Error:(19, 2) error: cannot find symbol class RunWith

Error:(23, 10) error: cannot find symbol class Test


when I import robolectric classes i do not see any errors so not sure why I’m getting the above failures, have I missed anything?



Test:


import org.robolectric.RobolectricTestRunner;
import org.junit.runner.RunWith;
import org.junit.Test;

import static junit.framework.Assert.assertTrue;




@RunWith(RobolectricTestRunner.class)

public class luttest{

        @Test
       
public void shouldFail() {
            assertTrue(false);
        }
    }






gradle file:



dependencies {
   
   

   
// Tests
   
testCompile 'junit:junit:4.12'
   
testCompile 'org.robolectric:robolectric:2.3'

}



my file structure is 'src/main/test/java/'



thanks 


Erich Douglass

unread,
Aug 11, 2015, 7:27:35 PM8/11/15
to robol...@googlegroups.com
You're using Robolectric 2.3 which is no longer supported. I'd suggest upgrading to 3.0. Also, there are some instructions here http://robolectric.org/getting-started on how to get started with 3.0, and some sample projects here https://github.com/robolectric/robolectric-samples if you want to look at some working examples.

--
You received this message because you are subscribed to the Google Groups "Robolectric" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robolectric...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

tester test

unread,
Aug 12, 2015, 2:33:08 AM8/12/15
to Robolectric
Managed to get it working - I had to remove the test directory from main and add a separate src.dir for tests

main {
   
    java.srcDirs = ['src/main/java']

   }


robolectric {
    java.srcDir file('src/test/java/')
    

Reply all
Reply to author
Forward
0 new messages