gpt4 book ai didi

java - 单元测试 Blobstore API

转载 作者:行者123 更新时间:2023-12-02 00:22:20 27 4
gpt4 key购买 nike

我正在尝试对一些使用 Blobstore API 的代码进行单元测试,但是我收到此代码的 NullPointerException :

@ContextConfiguration(locations = { "classpath:service/client-config.xml" })
@RunWith(SpringJUnit4ClassRunner.class)
public class BlobstoreDaoTest {
private final LocalServiceTestHelper helper =
new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig());
private final LocalBlobstoreServiceTestConfig config =
new LocalBlobstoreServiceTestConfig();

@Autowired
private BlobstoreDao dao;

@Before
public void setUp() {
config.setUp();
helper.setUp();
}

@After
public void tearDown() {
helper.tearDown();
config.tearDown();
}

@Test
public void doTest() {
// Code omitted
}
}

错误:

java.lang.NullPointerException
at com.google.appengine.tools.development.testing.LocalBlobstoreServiceTestConfig.setUp(LocalBlobstoreServiceTestConfig.java:52)

最佳答案

您可能想要的是以下内容:

public class BlobstoreDaoTest {
private LocalServiceTestHelper helper =
new LocalServiceTestHelper(
new LocalDatastoreServiceTestConfig(),
new LocalBlobstoreServiceTestConfig()
);

@Before
public void setUp() {
helper.setUp();
}

@After
public void tearDown() {
helper.tearDown();
}
...

关于java - 单元测试 Blobstore API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10712241/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com