友
我的IDEA拒绝看测试并咆哮:
java.lang.Exception: No tests found in class
at com.atlassian.plugins.osgi.test.AtlassianPluginsTestRunner.runViaRestCall(AtlassianPluginsTestRunner.java:125)
at com.atlassian.plugins.osgi.test.AtlassianPluginsTestRunner.run(AtlassianPluginsTestRunner.java:75)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
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)
我已经尝试了以下内容:
知道我还能尝试什么吗?
以下是代码:
atlassian.plugins.osgi.test.AtlassianPluginsTestRunner;
import com.atlassian.query.Query;
import com.idalko.jira.plugins.igrid.grid.JiraCompatibilityHandler;
import com.idalko.jira.plugins.igrid.rest.api.ApiResource;
import com.idalko.jira.plugins.igrid.services.FileResourceService;
import com.idalko.jira.plugins.igrid.services.SQLExecutor;
import org.apache.commons.io.FileUtils;
import org.apache.log4j.Logger;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.List;
import static org.junit.Assert.assertEquals;
/**
* Created by strygul on 3/23/17.
*/
@RunWith(AtlassianPluginsTestRunner.class)
public class GridSearchWiredTest {
public static final Logger LOG = Logger.getLogger(ApiResource.class);
private SearchService searchService;
private JiraCompatibilityHandler jiraCompatibilityHandler;
private final String SQL_BEFORE_FILE_PATH = "testcases/grid_search/before.sql";
private final String BACKUP_PATH = "jira-default-backup.zip";
private final String[] ZIP_EXTENSION = new String[]{"zip"};
private FileResourceService fileResourceService;
private SQLExecutor sqlExecutor;
public static final String DEFAULT_GRID_NAME = "GridSearchJiraCase_Grid";
// public GridSearchWiredTest(SearchService searchService, JiraCompatibilityHandler jiraCompatibilityHandler) {
// this.searchService = searchService;
// this.jiraCompatibilityHandler = jiraCompatibilityHandler;
// this.fileResourceService = new FileResourceService();
// this.sqlExecutor = new SQLExecutorImpl(fileResourceService);
// }
@Before
public void setUp() throws Exception {
restoreJiraData();
executeSql();
}
@Test
public void testSomething() {
JqlQueryBuilder osGiComponentInstanceOfType = ComponentAccessor.getOSGiComponentInstanceOfType(JqlQueryBuilder.class);
Query query = osGiComponentInstanceOfType.newBuilder().where().addFunctionCondition("issue", "grid", DEFAULT_GRID_NAME, "astring like 'test string 1'").buildQuery();
SearchResults results = jiraCompatibilityHandler.search(query, PagerFilter.getUnlimitedFilter());
List<Issue> issues = results.getIssues();
assertEquals(2, issues.size());
}
private void executeSql() throws URISyntaxException, IOException {
File sqlFile = fileResourceService.getFile(SQL_BEFORE_FILE_PATH);
sqlExecutor.executeSQL(sqlFile);
}
private void restoreJiraData() {
if(needToRestoreJira()) {
RestoreJiraData restoreJiraData = new SmartRestoreJiraData();
restoreJiraData.restore(BACKUP_PATH);
}
}
protected boolean needToRestoreJira() {
final String importFolder = "jira" + File.separator + "home" + File.separator + "import";
final File root;
try {
root = fileResourceService.getFile("").getParentFile();
} catch (URISyntaxException e) {
return false;
}
return FileUtils.listFiles(new File(root, importFolder), ZIP_EXTENSION, false).isEmpty();
}
}
答案 0 :(得分:1)
好的,我发现了问题所在。
这既不是Intellij的问题,也不是JUnit的问题。问题出在OSGI上。我忘了从我的插件中添加一个类到我的Test插件的导入。结果,它无法构建服务。