0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

JMockit使い方 自分のtest

Posted at

1.marven install

jmockit website : http://jmockit.github.io/gettingStarted.html

2.code demo

CDY52177Test_021.java
package CDY52177;

import java.sql.SQLException;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;

import jp.co.toyota.py35401.dba.CDY52177;
import jp.co.toyota.pzd0001.CFZD0002;
import jp.co.toyota.pzd0001.CFZD0003;
import mockit.Mock;
import mockit.MockUp;
import mockit.integration.junit4.JMockit;

//@RunWith({PowerMockRunner.class})
@RunWith(JMockit.class)
@PowerMockIgnore({ "javax.management.*" })
@PrepareForTest({ System.class})
public class CDY52177Test_021   extends CDY52177_TestBase{

	/**
	 *
	 * @throws SQLException
	 * @throws CFZD0002
	 * @throws CFZD0003
	 */
	//@Test//(expected=CFZD0002.class)
	@Test(expected=ExceptionInInitializerError.class)
	public void runTest227() throws SQLException, CFZD0002, CFZD0003
	{
		System.out.println("テストプログラム実行"+this.getTestClass());
		this.commonMock1();

		new MockUp<System>()
	    {
	        @Mock
	        public String getenv(String string) {
	            return "/gsms/localenv/y5env.dat";
	        }
	    };

		CDY52177.y5sys_EnvSet();
		//assertThat(ret, CoreMatchers.instanceOf(int.class));
	}

	@Override
	public void setUpParameters() {
		System.out.println("setUpParameters");
		super.setUpParameters();
        //select  no data
		try {


        } catch (Exception e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}

	}
}

重要なcomment:
@RunWith(JMockit.class)
@PrepareForTest({ System.class})

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?