首页 \ 问答 \ @Test之后的回滚事务(Rollback transaction after @Test)

@Test之后的回滚事务(Rollback transaction after @Test)

首先,我已经在StackOverflow上找到了很多关于这一点的线程,但是他们都没有真正帮助我,所以很抱歉要问可能的重复问题。

我使用spring-test运行JUnit测试,我的代码看起来像这样

@RunWith(SpringJUnit4ClassRunner.class)  
@ContextConfiguration(locations = {})
public class StudentSystemTest {

    @Autowired
    private StudentSystem studentSystem;

    @Before
    public void initTest() {
    // set up the database, create basic structure for testing
    }

    @Test
    public void test1() {
    }    
    ...  
}

我的问题是我希望我的测试不会影响其他测试。 所以我想为每个测试创建一些回滚的东西。 我已经搜索了很多,但是我迄今没有找到任何东西。 我正在使用Hibernate和MySql


First of all, I've found a lot of threads on StackOverflow about this, but none of them really helped me, so sorry to ask possibly duplicate question.

I'm running JUnit tests using spring-test, my code looks like this

@RunWith(SpringJUnit4ClassRunner.class)  
@ContextConfiguration(locations = {})
public class StudentSystemTest {

    @Autowired
    private StudentSystem studentSystem;

    @Before
    public void initTest() {
    // set up the database, create basic structure for testing
    }

    @Test
    public void test1() {
    }    
    ...  
}

My problem is that I want my tests to NOT influence other tests. So I'd like to create something like rollback for each test. I've searched a lot for this, but I've found nothing so far. I'm using Hibernate and MySql for this


原文:https://stackoverflow.com/questions/12626502
更新时间:2023-02-14 20:02

最满意答案

您应该参考Sitecore 7 Scaling Guide的第3.4章,该指南建议您使用Microsoft分布式文件系统 (如Jens所指出的)或Web部署工具

我已经实现了几次Web Deploy解决方案并且工作得很好,但是设置起来非常困难。
上次我必须实现文件同步时,DFS解决方案不是Scaling Guide的一部分,因此我无法对此发表评论。


You should refer to chapter 3.4 of the Sitecore 7 Scaling Guide which will suggest you to use Microsoft Distributed File System (as Jens pointed out) or the Web Deployment Tool.

I have implemented the Web Deploy solution a few times and that works pretty good, but it can be quite difficult to setup.
The DFS solution wasn't part of the Scaling Guide the last time I had to implement file synchronisation, so I can't comment on that.

相关问答

更多
  • 您应该参考Sitecore 7 Scaling Guide的第3.4章,该指南建议您使用Microsoft分布式文件系统 (如Jens所指出的)或Web部署工具 。 我已经实现了几次Web Deploy解决方案并且工作得很好,但是设置起来非常困难。 上次我必须实现文件同步时,DFS解决方案不是Scaling Guide的一部分,因此我无法对此发表评论。 You should refer to chapter 3.4 of the Sitecore 7 Scaling Guide which will sug ...
  • 您可以使用after_success:选项在travis-ci上实现自定义部署 。 就像是: after_success: "cd $subfolder && python setup.py sdist upload -r pypi" 您必须使用最适合的方法自行提供您的pypi凭证。 You can use the after_success: option to implement custom deployments on travis-ci. Something like: after_su ...
  • 多列表控件应该在内容编辑器中直接对用户可见,您不需要执行任何其他操作。 由于您使用标准值定义了一些项目,因此在首次创建该项目时将会“预先选择”这些项目。 然后,用户可以根据需要添加其他项目。 要允许用户从页面编辑器中选择值,您可以在PageEdit中使用Sitecore EditFrame 将项目呈现为原始值的原因是因为您需要获取项目然后迭代目标ID。 这里有一个例子 //Get a multilist field from the current item Sitecore.Data.Fields.Mul ...
  • 据我所知,您遇到以下问题: 创建自定义Azure SQL数据库服务以托管Sitecore数据库和自定义数据库。 Sitecore内容交付(交付场)和/或Sitecore内容管理(编辑场)应连接到此自定义服务中的数据库。 因此,Sitecore Azure模块必须使用自定义Azure SQL数据库服务,而不是创建新服务。 如果我是对的,问题的原因可能是由于错过了您之前提到的Sitecore KB文章的第16步。 16. Recycle the Sitecore Application Pool or rese ...
  • 答案是您需要将TDS更新包设置设置为命令行参数的一部分,因此: msbuild.exe /p:GeneratePackage=${generatePackage};PackageAuthor=${packageAuthor};PackagePublisher=${packagePublisher};etc... 这些设置也在visual studio解决方案中设置 - > TDS项目 - >属性。 如果我可以从视觉工作室中删除它们,我没有时间进行实验,但我希望我可以。 The answer is you ...
  • 我现在的问题是,在创建新构建时,使用Jenkins工作流从头开始部署环境也是不错的做法 是的,从零开始部署环境是一种好的做法。 就像你说的,詹金斯和詹金斯的管道当然可以帮助你根据你的具体要求开始和协调这个过程。 从头开始部署完整的环境是自动化最难的事情之一,如果这是自动化的,这意味着许多其他事情也是自动化的,例如基础架构,应用程序部署,应用程序配置等。 这是在现实生活中使用的东西吗? 当然是。 很多商店都这样做。 您的环境越简单,就越容易,因此,拥有一个后端应用程序的创业公司在实现这种瓦尔哈拉国家时将会遇到 ...
  • 我通过从WebPI安装Web Deploy来解决此问题。 由于某种原因,当我仅独立安装Web Deploy 3.6时,服务未正确注册。 通过WebPI安装后,发布作业立即开始工作。 I fixed this by installing Web Deploy from WebPI. For some reason when I only installed Web Deploy 3.6 independently the services were not registered properly. After ...
  • Sitecore Azure必须自动为Sitecore Core,Master和Web数据库创建Azure SQL数据库服务,并将数据从本地SQL Server数据库传输到云数据库。 您使用的Sitecore Azure版本是什么? 如果您希望可以手动将Sitecore数据库导出到您自己的Azure SQL数据库服务,然后强制模块使用它们。 请查看以下文章了解更多详情: https : //github.com/olegburov/sitecore-azure-content/blob/master/art ...
  • 我使用Sitecore Azure模块和使用Azure .NET SDK 2.5的Visual Studio看到了此错误。 尽管如此,我还没有看到SDK 2.4或2.6。 由于您无法将其他SDK版本与Sitecore Azure模块一起使用,因此您可以尝试再次运行部署。 否则,在Visual Studio中使用最新的Azure .NET SDK: https : //github.com/olegburov/sitecore-azure-content/blob/master/articles/how-to ...
  • 你应该使用CI工具和git一起使用 - 你可以用纯git钩子实现你的目标,但我强烈建议不要这样做。 以下是使用SemaphoreCI设置通用工作流的方法: https : //semaphoreci.com/docs/generic-deployment.html - 他们有非常好的和初学者友好的文档,如果您对CI主题有疑问,应该通过。 如果你有私人存储库(我猜你是因为你使用bb)并且你有预算,你可以使用http://codeship.com或https://circleci.com/,因为他们有免费套餐。 ...

相关文章

更多

最新问答

更多
  • sp_updatestats是否导致SQL Server 2005中无法访问表?(Does sp_updatestats cause tables to be inaccessible in SQL Server 2005?)
  • 如何创建一个可以与持续运行的服务交互的CLI,类似于MySQL的shell?(How to create a CLI that can interact with a continuously running service, similar to MySQL's shell?)
  • AESGCM解密失败的MAC(AESGCM decryption failing with MAC)
  • Zurb Foundation 4 - 嵌套网格对齐问题(Zurb Foundation 4 - Nested grid alignment issues)
  • 湖北京山哪里有修平板计算机的
  • SimplePie问题(SimplePie Problem)
  • 在不同的任务中,我们可以同时使用多少“上下文”?(How many 'context' we can use at a time simultaneously in different tasks?)
  • HTML / Javascript:从子目录启用文件夹访问(HTML/Javascript: Enabling folder access from a subdirectory)
  • 为什么我会收到链接错误?(Why do I get a linker error?)
  • 如何正确定义析构函数(How to properly define destructor)
  • 垂直切换菜单打开第3级父级。(Vertical toggle menu 3rd level parent stay opened. jQuery)
  • 类型不匹配 - JavaScript(Type mismatch - JavaScript)
  • 为什么当我将模型传递给我的.Net MVC 4控制器操作时,它坚持在部分更新中使用它?(Why is it that when I pass a Model to my .Net MVC 4 Controller Action it insists on using it in the Partial Update?)
  • 在使用熊猫和statsmodels时拉取变量名称(Pulling variable names when using pandas and statsmodels)
  • 如何开启mysql计划事件
  • 检查数组的总和是否大于最大数,反之亦然javascript(checking if sum of array is greater than max number and vice versa javascript)
  • 使用OpenGL ES绘制轮廓(Drawing Outline with OpenGL ES)
  • java日历格式(java Calendar format)
  • Python PANDAS:将pandas / numpy转换为dask数据框/数组(Python PANDAS: Converting from pandas/numpy to dask dataframe/array)
  • 如何搜索附加在elasticsearch索引中的文档的内容(How to search a content of a document attached in elasticsearch index)
  • LinQ to Entities:做相反的查询(LinQ to Entities: Doing the opposite query)
  • 从ExtJs 4.1商店中删除记录时会触发哪些事件(Which events get fired when a record is removed from ExtJs 4.1 store)
  • 运行javascript后如何截取网页截图[关闭](How to take screenshot of a webpage after running javascript [closed])
  • 如何使用GlassFish打印完整的堆栈跟踪?(How can I print the full stack trace with GlassFish?)
  • 如何获取某个exe应用程序的出站HTTP请求?(how to get the outbound HTTP request of a certain exe application?)
  • 嗨,Android重叠背景片段和膨胀异常(Hi, Android overlapping background fragment and inflate exception)
  • Assimp详细说明typedef(Assimp elaborated type refers to typedef)
  • 初始化继承类中不同对象的列表(initialize list of different objects in inherited class)
  • 使用jquery ajax在gridview行中保存星级评分(Save star rating in a gridview row using jquery ajax)
  • Geoxml3 groundOverlay zIndex(Geoxml3 groundOverlay zIndex)