alibaba / testable-mock

换种思路写Mock,让单元测试更简单
https://alibaba.github.io/testable-mock/
MIT License
1.83k stars 310 forks source link

BigDecimial and date bug still exist in version 0.7.5 #279

Closed xushijiaxuhuanhuan closed 2 years ago

xushijiaxuhuanhuan commented 2 years ago

BigDecimial and date bug still exist in version 0.7.5

linfan commented 2 years ago

Do you mean issue https://github.com/alibaba/testable-mock/issues/145 ?

I tried below test with TestableMock 0.7.5, and it works well. Could you provide more information about the issue ?

public class CreateBigDecimalTest {

    @Test
    public void testBigDecimals() {
        BigDecimal bigDecimal = OmniConstructor.newInstance(BigDecimal.class);
        assertEquals(0, bigDecimal.intValue());
    }

    @Test
    public void testDate() {
        Date date = OmniConstructor.newInstance(Date.class);
        assertTrue(date.getTime() > 0);
    }

}
xushijiaxuhuanhuan commented 2 years ago

文件已查收!

linfan commented 2 years ago

I should mention that, you need to enable the byte-code enhancement for omni constructor by adding below content into your testable.properties file:

omni.constructor.enhance.enable = true

Check the doc for more details. https://alibaba.github.io/testable-mock/#/zh-cn/doc/omni-constructor

xushijiaxuhuanhuan commented 2 years ago

文件已查收!