菜鸟教程小白 发表于 2022-12-12 16:14:14

ios - 测试在 Xcode 中通过,但在 Circle CI 中失败


                                            <p><p><strong>问题:</strong>对于<a href="https://github.com/TTTAttributedLabel/TTTAttributedLabel/pull/573" rel="noreferrer noopener nofollow">this pull request</a> ,测试没有通过 CircleCI,但测试在本地通过。为什么?</p>

<hr/>

<p><a href="https://circleci.com/gh/TTTAttributedLabel/TTTAttributedLabel/82" rel="noreferrer noopener nofollow">CircleCI test output</a>显示所有 <code>FBSnapshotTestCase</code> 测试的失败。例如:</p>

<blockquote>
<p>✗ testAdjustsFontSizeToFitWidth, ((comparisonSuccess__) is true) failed - Snapshot comparison failed: Error Domain=FBSnapshotTestControllerErrorDomain Code=1 &#34;Unable to load reference image.&#34; UserInfo=0x7f85f36b0a50 {NSLocalizedFailureReason=<strong>Reference image not found. You need to run the test in record mode</strong>, NSLocalizedDescription=Unable to load reference image., FBReferenceImageFilePathKey=/Users/distiller/TTTAttributedLabel/Example/TTTAttributedLabelTests/ReferenceImages_32/TTTAttributedLabelTests/[email protected]}</p>

<p>[…]</p>

<p>✗ testAttributedTruncationToken, ((comparisonSuccess__) is true) failed - Snapshot comparison failed: Error Domain=FBSnapshotTestControllerErrorDomain Code=1 &#34;Unable to load reference image.&#34; UserInfo=0x7f85f35b06d0 {NSLocalizedFailureReason=<strong>Reference image not found. You need to run the test in record mode</strong>, NSLocalizedDescription=Unable to load reference image., FBReferenceImageFilePathKey=/Users/distiller/TTTAttributedLabel/Example/TTTAttributedLabelTests/ReferenceImages_32/TTTAttributedLabelTests/[email protected]}</p>
</blockquote>

<p>但是,相同的测试在本地通过:</p>

<p> <img src="https://cloud.githubusercontent.com/assets/789577/9699801/8c0d2d36-53b4-11e5-9a93-dfec43af0519.png" alt="image"/> </p>

<p>在 CircleCI 上,测试使用不存在的 <code>ReferenceImages_32</code> 目录:</p>

<pre><code>/Users/distiller/TTTAttributedLabel/Example/TTTAttributedLabelTests/ReferenceImages_32/TTTAttributedLabelTests/[email protected]
</code></pre>

<p>但是,图像确实存在于 <code>ReferenceImages_64</code> 中。我希望使用 <code>_64</code> 目录,因为 <code>circle.yml</code> 文件指定使用 iPhone 6 模拟器:</p>

<pre><code>dependencies:
pre:
    - xcrun instruments -w &#34;iPhone 6 (8.3 Simulator)&#34; || exit 0
override:   
    - sudo gem install cocoapods xcpretty obcd -N
    - pod install --project-directory=Example
test:
override:
    - set -o pipefail &amp;&amp; xcodebuild -workspace &#39;Example/Espressos.xcworkspace&#39; -scheme &#39;Espressos&#39;
      -sdk iphonesimulator -destination &#34;platform=iOS Simulator,name=iPhone 6&#34;
      GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES clean test | xcpretty -c
      --report junit --output ${CIRCLE_TEST_REPORTS}/junit.xml
</code></pre>

<ul>
<li>这是什么原因造成的?</li>
<li>如何在 CircleCI 上通过测试?</li>
<li>可能相关:<a href="https://github.com/facebook/ios-snapshot-test-case/issues/102" rel="noreferrer noopener nofollow">this <code>FBSnapshotTestCase</code> issue</a> </li>
</ul></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您是否尝试过在没有缓存的情况下运行构建?这通常可以为我解决这些问题。要构建无缓存,只需单击右上角的按钮。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 测试在 Xcode 中通过,但在 Circle CI 中失败,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/32414627/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/32414627/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 测试在 Xcode 中通过,但在 Circle CI 中失败