I am using Intellij Idea version 12 (ultimate). Just installed Team City (version 8). One default agent, running in linux.
I've created a very simple test application:
public class Main { public static void main(String[] args) { System.out.println("Hello World!"); } public int sum(int x, int y) { return x+y; } }
... and a very simple test...
import junit.framework.Assert; import org.junit.Test; public class MainTest { @Test public void testSum() throws Exception { Main test=new Main(); Assert.assertEquals("Sum should be 7",7,test.sum(4,4)); } }
If I run this in IntelliJ, the test gets run and fails just like it should.
If instead I commit this project and push it up to github, TeamCity sees the change and begins a build. The build fails fairly quickly with 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("Sum should be 7. Loser!!",7,test.sum(4,4)); ^
So yeah, I see that TeamCity is not seeing JUnit.
On the TeamCity Discussion forum, one respondent to my question there asked me if junit.jar was added as a dependency (module or library) in the build. It was listed as a module dependency, but for kicks I tried it as a library dependency. I also tried checking and unchecking export and trying the compile and test scopes, but each time I get the same errors. My run configuration is shared.
I am not using Ant or Maven. Perhaps someday, but I'd like to start as simple as possible.
Clearly, I'm missing something, but the documentation on the subject is sparse.
Thank you.