package junit.framework does not exist

Good morning -

I'm a somewhat long time user of intellij idea, and love it. We are looking to start using TeamCity in our department, and so I've been working with it the past few days to see if it's a fit.

One thing I've run into - and I'm sure this is a newbie question - is testing.

In idea, our unit tests (junit 4) run great. In teamcity, I receive the following errors:

/home/ctb/TeamCity/buildAgent/work/742505fa88794219/test/MainTest.java:1: package junit.framework does not exist

import junit.framework.Assert;
 

                      ^
/home/ctb/TeamCity/buildAgent/work/742505fa88794219/test/MainTest.java:2: package org.junit does not exist
import org.junit.Test;
                ^
/home/ctb/TeamCity/buildAgent/work/742505fa88794219/test/MainTest.java:12: cannot find symbol
symbol  : class Test
location: class MainTest
    @Test
         ^
/home/ctb/TeamCity/buildAgent/work/742505fa88794219/test/MainTest.java:15: cannot find symbol
symbol  : variable Assert
location: class MainTest
        Assert.assertEquals....

My build step is of type 'intellij project'.

I'm sure there's just something I dont know yet that's hanging me up. Any help would be appreciated.

Thank you!

6 comments
Comment actions Permalink

Further research revels that perhaps I need to add the path to the junit jar somewhere in the build. Not sure where to do that.

Also, I want to point out that I'm not using ant or maven.

Thanks again.

0
Comment actions Permalink

Do you have junit.jar added as library or module dependency in your project?

0
Comment actions Permalink

I did not have junit as a dependency,  so I tried adding it as a module first and then as a library. In both cases I received the same errors as before.

I also tried checking export (and unchecking) in the module dependency tab.

I am not using Ant or Maven.

0
Comment actions Permalink

Could you please attach .idea directory and .iml files from your project to this thread?

0
Comment actions Permalink

Sure thing. Here you go. THank you, I appreciate your help with what is undoubtedly a simple question.



Attachment(s):
NewJavaTest.zip
0
Comment actions Permalink

Seems the problem is that junit.jar is not placed in version control under your project. In order to build your project on TeamCity agent, the project ideally should be self contained. In your case junit.jar only exists on your local machine, I suppose there is no such file on agent at required location. So you have two options actually: put junit.jar under version control into your project, or define global library in IDEA and configure this global library on IDEA Project runner page (Check/Reparse must be started), after that put library files on all of the agents where your build will be executed. Personally, I think the first approach is much simpler and better.

0

Please sign in to leave a comment.